Skip to content
Snippets Groups Projects
Commit 192e70df authored by Adam G-H's avatar Adam G-H
Browse files

Issue #3315798 by phenaproxima, tedbow: Post-apply always fails during cron

parent 7aa0e075
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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');
}
......
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