From 4f3e67714e38c74eb6568d62dae0a0d2b186ec37 Mon Sep 17 00:00:00 2001 From: Toby Zerner Date: Sat, 22 Jul 2017 11:43:50 +0930 Subject: [PATCH] Fix incorrect migration notes for extensions without any migrations When running migrations for an extension without any migrations (eg. BBCode), the migration notes for the previous extension were being displayed, because the Migrator never had a chance to clear them. --- src/Extension/ExtensionManager.php | 5 +++++ src/Update/Console/MigrateCommand.php | 6 ++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Extension/ExtensionManager.php b/src/Extension/ExtensionManager.php index 54ffc008c..69ab289d9 100644 --- a/src/Extension/ExtensionManager.php +++ b/src/Extension/ExtensionManager.php @@ -219,6 +219,7 @@ class ExtensionManager * * @param Extension $extension * @param bool|true $up + * @return array Notes from the migrator. */ public function migrate(Extension $extension, $up = true) { @@ -234,7 +235,11 @@ class ExtensionManager } else { $this->migrator->reset($migrationDir, $extension); } + + return $this->migrator->getNotes(); } + + return []; } /** diff --git a/src/Update/Console/MigrateCommand.php b/src/Update/Console/MigrateCommand.php index e345beeca..1f2c62f83 100644 --- a/src/Update/Console/MigrateCommand.php +++ b/src/Update/Console/MigrateCommand.php @@ -69,8 +69,6 @@ class MigrateCommand extends AbstractCommand $extensions = $this->container->make('Flarum\Extension\ExtensionManager'); - $migrator = $extensions->getMigrator(); - foreach ($extensions->getExtensions() as $name => $extension) { if (! $extension->isEnabled()) { continue; @@ -78,9 +76,9 @@ class MigrateCommand extends AbstractCommand $this->info('Migrating extension: '.$name); - $extensions->migrate($extension); + $notes = $extensions->migrate($extension); - foreach ($migrator->getNotes() as $note) { + foreach ($notes as $note) { $this->info($note); } }