From ac553b727427d0c913aa18424f5941ed9e6a10bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Harold=20Ju=C3=A1rez?= Date: Thu, 23 May 2019 12:48:42 -0600 Subject: [PATCH] [update:execute] Fixed update table (#4060) --- src/Command/Update/ExecuteCommand.php | 58 ++++++++++++++------------- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/src/Command/Update/ExecuteCommand.php b/src/Command/Update/ExecuteCommand.php index 86802fa19..412f7ae69 100644 --- a/src/Command/Update/ExecuteCommand.php +++ b/src/Command/Update/ExecuteCommand.php @@ -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( @@ -158,19 +158,34 @@ 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()); @@ -178,10 +193,11 @@ protected function execute(InputInterface $input, OutputInterface $output) } } - // 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']); } @@ -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; } @@ -314,7 +317,7 @@ private function runPostUpdates() $this->chainQueue->addCommand('update:entities'); - return true; + return 1; } protected function getUpdates($module = null) @@ -338,7 +341,6 @@ protected function getUpdateList() { $start = []; $updates = update_get_update_list(); - foreach ($updates as $module => $update) { $start[$module] = $update['start']; }