diff --git a/src/CronUpdater.php b/src/CronUpdater.php index 5239aa9161083bf08d01736339f10b312d073e71..5af93a252d31cff8b4b42e0ce2ddadb3c90c5026 100644 --- a/src/CronUpdater.php +++ b/src/CronUpdater.php @@ -280,6 +280,15 @@ class CronUpdater extends Updater { * An empty 200 response if the post-apply tasks succeeded. */ public function handlePostApply(string $stage_id, string $installed_version, string $target_version): Response { + $owner = $this->tempStore->getMetadata(static::TEMPSTORE_LOCK_KEY) + ->getOwnerId(); + // Reload the tempstore with the correct owner ID so we can claim the stage. + // We use \Drupal::service() here because, given what we inherit from the + // parent class, there's no clean way to inject the shared tempstore + // factory. + $this->tempStore = \Drupal::service('tempstore.shared') + ->get('package_manager_stage', $owner); + $this->claim($stage_id); // Run post-apply tasks in their own try-catch block so that, if anything diff --git a/tests/src/Build/CoreUpdateTest.php b/tests/src/Build/CoreUpdateTest.php index e0e49cf5ef74fb2d7c814a94ed487d0f625dd357..55f1ebcfbc300865518aec16fc6d8b9416986672 100644 --- a/tests/src/Build/CoreUpdateTest.php +++ b/tests/src/Build/CoreUpdateTest.php @@ -121,11 +121,30 @@ class CoreUpdateTest extends UpdateTestBase { */ public function testCron(string $template): void { $this->createTestProject($template); + // Install dblog so we can check if any errors were logged during the update. + $this->installModules(['dblog']); $this->visit('/admin/reports/status'); $mink = $this->getMink(); - $mink->assertSession()->pageTextContains('Your site is ready for automatic updates.'); - $mink->getSession()->getPage()->clickLink('Run cron'); + $page = $mink->getSession()->getPage(); + $assert_session = $mink->assertSession(); + + $assert_session->pageTextContains('Your site is ready for automatic updates.'); + $page->clickLink('Run cron'); + $assert_session->statusCodeEquals(200); + + // There should be log messages, but no errors or warnings should have been + // logged by Automatic Updates. + $this->visit('/admin/reports/dblog'); + $assert_session->pageTextNotContains('No log messages available.'); + $page->selectFieldOption('Type', 'automatic_updates'); + $page->selectFieldOption('Severity', 'Emergency', TRUE); + $page->selectFieldOption('Severity', 'Alert', TRUE); + $page->selectFieldOption('Severity', 'Critical', TRUE); + $page->selectFieldOption('Severity', 'Warning', TRUE); + $page->pressButton('Filter'); + $assert_session->pageTextContains('No log messages available.'); + $this->assertUpdateSuccessful('9.8.1'); }