Skip to content
Snippets Groups Projects
Commit 1edb15aa authored by Ted Bowman's avatar Ted Bowman
Browse files

Issue #3406008: Status report still lists DB updates error after running update.php

parent 2bfe0e0a
No related branches found
Tags 3.0.0-beta2
1 merge request!988Resolve #3406008 "Status update php"
......@@ -79,23 +79,19 @@ class StatusCheckerRunAfterUpdateTest extends UpdaterFormTestBase {
$page->clickLink('Apply pending updates');
$this->checkForMetaRefresh();
$assert_session->pageTextContains('Updates were attempted.');
// PendingUpdatesValidator prevented the update to complete, so the status
// checks weren't run.
$this->drupalGet('/admin');
$assert_session->pageTextContains('Your site has not recently run an update readiness check. Rerun readiness checks now.');
}
else {
$page->pressButton('Continue');
$this->checkForMetaRefresh();
$assert_session->addressEquals('/admin/reports/updates');
$assert_session->pageTextContainsOnce('Update complete!');
// Status checks should display errors on admin page.
$this->drupalGet('/admin');
// Confirm that the status checks were run and the new error is displayed.
$assert_session->statusMessageContains('Error before continue.', 'error');
$assert_session->statusMessageContains('Your site does not pass some readiness checks for automatic updates. It cannot be automatically updated until further action is performed.', 'error');
$assert_session->pageTextNotContains('Your site has not recently run an update readiness check. Rerun readiness checks now.');
}
// Status checks should display errors on admin page.
$this->drupalGet('/admin');
// Confirm that the status checks were run and the new error is displayed.
$assert_session->statusMessageContains('Error before continue.', 'error');
$assert_session->statusMessageContains('Your site does not pass some readiness checks for automatic updates. It cannot be automatically updated until further action is performed.', 'error');
$assert_session->pageTextNotContains('Your site has not recently run an update readiness check. Rerun readiness checks now.');
}
}
......@@ -4,6 +4,7 @@ declare(strict_types = 1);
namespace Drupal\automatic_updates;
use Drupal\automatic_updates\Validation\StatusChecker;
use Drupal\Core\Url;
use Drupal\system\Controller\DbUpdateController;
use Symfony\Component\HttpFoundation\RedirectResponse;
......@@ -259,6 +260,12 @@ final class BatchProcessor {
* @see automatic_updates_batch_alter()
*/
public static function dbUpdateBatchFinished(bool $success, array $results, array $operations): void {
// Run status checks after database updates are completed to ensure that
// PendingUpdatesValidator does not report any errors.
// @see \Drupal\package_manager\Validator\PendingUpdatesValidator
/** @var \Drupal\automatic_updates\Validation\StatusChecker $status_checker */
$status_checker = \Drupal::service(StatusChecker::class);
$status_checker->run();
DbUpdateController::batchFinished($success, $results, $operations);
// Now that the update is done, we can put the site back online if it was
// previously not in maintenance mode.
......
......@@ -64,12 +64,15 @@ final class UpdateController extends ControllerBase {
* A redirect to the appropriate destination.
*/
public function onFinish(Request $request): RedirectResponse {
$this->statusChecker->run();
if ($this->pendingUpdatesValidator->updatesExist()) {
// If there are pending database updates then the status checks will be
// run after the database updates are completed.
// @see \Drupal\automatic_updates\BatchProcessor::dbUpdateBatchFinished
$message = $this->t('Apply database updates to complete the update process.');
$url = Url::fromRoute('system.db_update');
}
else {
$this->statusChecker->run();
$message = $this->t('Update complete!');
$url = Url::fromRoute('update.status');
// Now that the update is done, we can put the site back online if it was
......
......@@ -75,23 +75,19 @@ class StatusCheckerRunAfterUpdateTest extends UpdaterFormTestBase {
$page->clickLink('Apply pending updates');
$this->checkForMetaRefresh();
$assert_session->pageTextContains('Updates were attempted.');
// PendingUpdatesValidator prevented the update to complete, so the status
// checks weren't run.
$this->drupalGet('/admin');
$assert_session->pageTextContains('Your site has not recently run an update readiness check. Rerun readiness checks now.');
}
else {
$page->pressButton('Continue');
$this->checkForMetaRefresh();
$assert_session->addressEquals('/admin/reports/updates');
$assert_session->pageTextContainsOnce('Update complete!');
// Status checks should display errors on admin page.
$this->drupalGet('/admin');
// Confirm that the status checks were run and the new error is displayed.
$assert_session->statusMessageContains('Error before continue.', 'error');
$assert_session->statusMessageContains('Your site does not pass some readiness checks for automatic updates. It cannot be automatically updated until further action is performed.', 'error');
$assert_session->pageTextNotContains('Your site has not recently run an update readiness check. Rerun readiness checks now.');
}
// Status checks should display errors on admin page.
$this->drupalGet('/admin');
// Confirm that the status checks were run and the new error is displayed.
$assert_session->statusMessageContains('Error before continue.', 'error');
$assert_session->statusMessageContains('Your site does not pass some readiness checks for automatic updates. It cannot be automatically updated until further action is performed.', 'error');
$assert_session->pageTextNotContains('Your site has not recently run an update readiness check. Rerun readiness checks now.');
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment