diff --git a/src/Commands/config/ConfigImportCommands.php b/src/Commands/config/ConfigImportCommands.php index 2d729e238d..f7eb94972e 100644 --- a/src/Commands/config/ConfigImportCommands.php +++ b/src/Commands/config/ConfigImportCommands.php @@ -260,23 +260,17 @@ public function doImport($storage_comparer): void if (isset($context['message'])) { $this->logger()->notice(str_replace('Synchronizing', 'Synchronized', (string)$context['message'])); } - - // Installing and uninstalling modules might trigger - // batch operations. Let's process them here. - // @see \Drush\Commands\pm\PmCommands::install() - if ($step === 'processExtensions' && batch_get()) { - drush_backend_batch_process(); - } } while ($context['finished'] < 1); } // Clear the cache of the active config storage. $this->getConfigCache()->deleteAll(); } + if ($config_importer->getErrors()) { throw new ConfigException('Errors occurred during import'); - } else { - $this->logger()->success('The configuration was imported successfully.'); } + + $this->logger()->success('The configuration was imported successfully.'); } catch (ConfigException $e) { // Return a negative result for UI purposes. We do not differentiate // between an actual synchronization error and a failed lock, because @@ -288,6 +282,13 @@ public function doImport($storage_comparer): void watchdog_exception('config_import', $e); throw new \Exception($message, $e->getCode(), $e); + } finally { + // Importing config might trigger batch operations (such as when installing and uninstalling modules). + // @see \Drush\Commands\pm\PmCommands::install() + if (batch_get()) { + $this->logger()->notice('Running batch operations...'); + drush_backend_batch_process(); + } } } }