Skip to content

Commit

Permalink
[update:execute] Fixed update table (#4060)
Browse files Browse the repository at this point in the history
  • Loading branch information
hjuarez20 authored and enzolutions committed May 23, 2019
1 parent db15e4e commit ac553b7
Showing 1 changed file with 30 additions and 28 deletions.
58 changes: 30 additions & 28 deletions src/Command/Update/ExecuteCommand.php
Expand Up @@ -133,10 +133,10 @@ protected function execute(InputInterface $input, OutputInterface $output)
$updates = update_resolve_dependencies($start);
$dependencyMap = [];
$allowUpdate = false;

foreach ($updates as $function => $update) {
$dependencyMap[$function] = !empty($update['reverse_paths']) ? array_keys($update['reverse_paths']) : [];
}

if (!$this->checkUpdates($start, $updates)) {
if ($this->module === 'all') {
$this->getIo()->info(
Expand All @@ -158,30 +158,46 @@ protected function execute(InputInterface $input, OutputInterface $output)
}
$this->getIo()->info('');
} else {
$this->showUpdateTable($updates, $this->trans('commands.update.execute.messages.pending-updates'));
$updateList = update_get_update_list();
$this->showUpdateTable($this->module === 'all' ? $updateList: $updateList[$this->module], $this->trans('commands.update.execute.messages.pending-updates'));

$allowUpdate = $this->getIo()->confirm(
$this->trans('commands.update.execute.questions.update'),
true
);
}

// Handle Post update to execute
$allowPostUpdate = false;
if(!$postUpdates = $this->postUpdateRegistry->getPendingUpdateInformation()) {
$this->getIo()->info(
$this->trans('commands.update.execute.messages.no-pending-post-updates')
);
} else {
$this->showPostUpdateTable($postUpdates, $this->trans('commands.update.execute.messages.pending-post-updates'));
$allowPostUpdate = $this->getIo()->confirm(
$this->trans('commands.update.execute.questions.post-update'),
true
);
}

if($allowUpdate) {
try {
if($allowUpdate) {
$this->runUpdates(
$updates
);
}
$this->runUpdates(
$updates
);
} catch (\Exception $e) {
watchdog_exception('update', $e);
$this->getIo()->error($e->getMessage());
return 1;
}
}

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

if($postUpdates || $allowUpdate) {
if($allowPostUpdate || $allowUpdate) {
$this->chainQueue->addCommand('cache:rebuild', ['cache' => 'all']);
}

Expand Down Expand Up @@ -266,25 +282,12 @@ private function runUpdates(
}

/**
* @param array $postUpdates
* @return bool
*/
private function runPostUpdates()
private function runPostUpdates($postUpdates)
{
if(!$postUpdates = $this->postUpdateRegistry->getPendingUpdateInformation()) {
$this->getIo()->info(
$this->trans('commands.update.execute.messages.no-pending-post-updates')
);
return 0;
}

$this->showPostUpdateTable($postUpdates, $this->trans('commands.update.execute.messages.pending-post-updates'));

$allowPostUpdate = $this->getIo()->confirm(
$this->trans('commands.update.execute.questions.post-update'),
true
);

if(!$allowPostUpdate) {
if(!$postUpdates) {
return 0;
}

Expand Down Expand Up @@ -314,7 +317,7 @@ private function runPostUpdates()

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

return true;
return 1;
}

protected function getUpdates($module = null)
Expand All @@ -338,7 +341,6 @@ protected function getUpdateList()
{
$start = [];
$updates = update_get_update_list();

foreach ($updates as $module => $update) {
$start[$module] = $update['start'];
}
Expand Down

0 comments on commit ac553b7

Please sign in to comment.