Skip to content

Commit

Permalink
[update:execute] run trailing post updates if there is no updates (#3996
Browse files Browse the repository at this point in the history
)

* run trailing post updates if there is no updates

* current master is not compatible with actual core 1.8

* fix runPostUpdates argument missing

* revert drupal/console-core version

* use new maintenance mode
  • Loading branch information
lalop authored and LOBsTerr committed Apr 23, 2019
1 parent f463c75 commit 7f914f7
Showing 1 changed file with 16 additions and 29 deletions.
45 changes: 16 additions & 29 deletions src/Command/Update/ExecuteCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ protected function configure()
$this->trans('commands.update.execute.options.update-n'),
'9000'
)
->setAliases(['upex']);
->setAliases(['upex'])
->enableMaintenance();
}

/**
Expand Down Expand Up @@ -151,38 +152,23 @@ protected function execute(InputInterface $input, OutputInterface $output)
)
);
}

return 0;
}

$maintenanceMode = $this->state->get('system.maintenance_mode', false);

if (!$maintenanceMode) {
$this->getIo()->info($this->trans('commands.site.maintenance.description'));
$this->state->set('system.maintenance_mode', true);
}

try {
$this->runUpdates(
$updates
);

// Post Updates are only safe to run after all schemas have been updated.
if (!$this->getUpdates()) {
$this->runPostUpdates();
} else {
try {
$this->runUpdates(
$updates
);
} catch (\Exception $e) {
watchdog_exception('update', $e);
$this->getIo()->error($e->getMessage());
return 1;
}
} catch (\Exception $e) {
watchdog_exception('update', $e);
$this->getIo()->error($e->getMessage());
return 1;
}

if (!$maintenanceMode) {
$this->state->set('system.maintenance_mode', false);
$this->getIo()->info($this->trans('commands.site.maintenance.messages.maintenance-off'));
}


// Post Updates are only safe to run after all schemas have been updated.
if (!$this->getUpdates()) {
$this->runPostUpdates($postUpdates);

$this->chainQueue->addCommand('update:entities');
}

Expand Down Expand Up @@ -274,6 +260,7 @@ private function runUpdates(
private function runPostUpdates()
{
$postUpdates = $this->postUpdateRegistry->getPendingUpdateInformation();

foreach ($postUpdates as $module => $updates) {
foreach ($updates['pending'] as $updateName => $update) {
$this->getIo()->info(
Expand Down

0 comments on commit 7f914f7

Please sign in to comment.