1
0
mirror of https://github.com/flarum/core.git synced 2025-07-16 14:26:25 +02:00

Re-run update check after update operations

This commit is contained in:
SychO9
2021-11-20 16:48:28 +01:00
parent 3497028cc0
commit fd70b46c91
7 changed files with 34 additions and 21 deletions

View File

@ -55,12 +55,8 @@ class GlobalUpdateHandler
throw new ComposerUpdateFailedException('*', $output->getContents()); throw new ComposerUpdateFailedException('*', $output->getContents());
} }
$this->commandDispatcher->dispatch(
new CheckForUpdates($command->actor)
);
$this->events->dispatch( $this->events->dispatch(
new FlarumUpdated(FlarumUpdated::GLOBAL) new FlarumUpdated($command->actor, FlarumUpdated::GLOBAL)
); );
return true; return true;

View File

@ -84,10 +84,8 @@ class MajorUpdateHandler
return true; return true;
} }
$this->lastUpdateCheck->forgetAll();
$this->events->dispatch( $this->events->dispatch(
new FlarumUpdated(FlarumUpdated::MAJOR) new FlarumUpdated($command->actor, FlarumUpdated::MAJOR)
); );
return true; return true;

View File

@ -68,10 +68,8 @@ class MinorUpdateHandler
throw new ComposerUpdateFailedException('flarum/*', $output->getContents()); throw new ComposerUpdateFailedException('flarum/*', $output->getContents());
} }
$this->lastUpdateCheck->forgetAll();
$this->events->dispatch( $this->events->dispatch(
new FlarumUpdated(FlarumUpdated::MINOR) new FlarumUpdated($command->actor, FlarumUpdated::MINOR)
); );
return true; return true;

View File

@ -9,19 +9,27 @@
namespace Flarum\PackageManager\Event; namespace Flarum\PackageManager\Event;
use Flarum\User\User;
class FlarumUpdated class FlarumUpdated
{ {
public const GLOBAL = 'global'; public const GLOBAL = 'global';
public const MAJOR = 'major'; public const MAJOR = 'major';
public const MINOR = 'minor'; public const MINOR = 'minor';
/**
* @var User
*/
public $actor;
/** /**
* @var string * @var string
*/ */
public $type; public $type;
public function __construct(string $type) public function __construct(User $actor, string $type)
{ {
$this->actor = $actor;
$this->type = $type; $this->type = $type;
} }
} }

View File

@ -79,9 +79,4 @@ class LastUpdateCheck
} }
} }
} }
public function forgetAll(): void
{
$this->save([]);
}
} }

View File

@ -10,13 +10,15 @@
namespace Flarum\PackageManager\Listener; namespace Flarum\PackageManager\Listener;
use Composer\Command\ClearCacheCommand; use Composer\Command\ClearCacheCommand;
use Flarum\Bus\Dispatcher;
use Flarum\Database\Console\MigrateCommand; use Flarum\Database\Console\MigrateCommand;
use Flarum\Foundation\Console\AssetsPublishCommand; use Flarum\Foundation\Console\AssetsPublishCommand;
use Flarum\PackageManager\Command\CheckForUpdates;
use Flarum\PackageManager\Event\FlarumUpdated; use Flarum\PackageManager\Event\FlarumUpdated;
use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\NullOutput; use Symfony\Component\Console\Output\NullOutput;
class PostUpdateListener class FlarumUpdateListener
{ {
/** /**
* @var ClearCacheCommand * @var ClearCacheCommand
@ -33,11 +35,23 @@ class PostUpdateListener
*/ */
private $migrate; private $migrate;
public function __construct(ClearCacheCommand $clearCache, AssetsPublishCommand $publishAssets, MigrateCommand $migrate) /**
* @var Dispatcher
*/
private $bus;
/**
* @param ClearCacheCommand $clearCache
* @param AssetsPublishCommand $publishAssets
* @param MigrateCommand $migrate
* @param Dispatcher $bus
*/
public function __construct(ClearCacheCommand $clearCache, AssetsPublishCommand $publishAssets, MigrateCommand $migrate, Dispatcher $bus)
{ {
$this->clearCache = $clearCache; $this->clearCache = $clearCache;
$this->publishAssets = $publishAssets; $this->publishAssets = $publishAssets;
$this->migrate = $migrate; $this->migrate = $migrate;
$this->bus = $bus;
} }
/** /**
@ -48,5 +62,9 @@ class PostUpdateListener
$this->clearCache->run(new ArrayInput([]), new NullOutput()); $this->clearCache->run(new ArrayInput([]), new NullOutput());
$this->migrate->run(new ArrayInput([]), new NullOutput()); $this->migrate->run(new ArrayInput([]), new NullOutput());
$this->publishAssets->run(new ArrayInput([]), new NullOutput()); $this->publishAssets->run(new ArrayInput([]), new NullOutput());
$this->bus->dispatch(
new CheckForUpdates($event->actor)
);
} }
} }

View File

@ -24,7 +24,7 @@ use Monolog\Handler\RotatingFileHandler;
use Monolog\Logger; use Monolog\Logger;
use Flarum\PackageManager\Event\FlarumUpdated; use Flarum\PackageManager\Event\FlarumUpdated;
use Flarum\PackageManager\Extension\Event\Updated; use Flarum\PackageManager\Extension\Event\Updated;
use Flarum\PackageManager\Listener\PostUpdateListener; use Flarum\PackageManager\Listener\FlarumUpdateListener;
class PackageManagerServiceProvider extends AbstractServiceProvider class PackageManagerServiceProvider extends AbstractServiceProvider
{ {
@ -89,6 +89,6 @@ class PackageManagerServiceProvider extends AbstractServiceProvider
} }
); );
$events->listen(FlarumUpdated::class, PostUpdateListener::class); $events->listen(FlarumUpdated::class, FlarumUpdateListener::class);
} }
} }