Skip to content
Snippets Groups Projects
Commit 8d56ffab authored by Kunal Sachdev's avatar Kunal Sachdev Committed by Adam G-H
Browse files

Issue #3265873 by kunal.sachdev: Destroy the update stage if there is an error...

Issue #3265873 by kunal.sachdev: Destroy the update stage if there is an error requiring a core version
parent a7913951
No related branches found
No related tags found
1 merge request!216Issue #3265873: Destroy the update stage if there is an error requiring a core version
...@@ -95,6 +95,7 @@ class BatchProcessor { ...@@ -95,6 +95,7 @@ class BatchProcessor {
static::getUpdater()->claim($stage_id)->stage(); static::getUpdater()->claim($stage_id)->stage();
} }
catch (\Throwable $e) { catch (\Throwable $e) {
static::clean($stage_id, $context);
static::handleException($e, $context); static::handleException($e, $context);
} }
} }
......
...@@ -4,6 +4,7 @@ namespace Drupal\Tests\automatic_updates\Functional; ...@@ -4,6 +4,7 @@ namespace Drupal\Tests\automatic_updates\Functional;
use Drupal\automatic_updates\Event\ReadinessCheckEvent; use Drupal\automatic_updates\Event\ReadinessCheckEvent;
use Drupal\automatic_updates_test\Datetime\TestTime; use Drupal\automatic_updates_test\Datetime\TestTime;
use Drupal\package_manager\Event\PostRequireEvent;
use Drupal\package_manager\Event\PreApplyEvent; use Drupal\package_manager\Event\PreApplyEvent;
use Drupal\package_manager\Event\PreCreateEvent; use Drupal\package_manager\Event\PreCreateEvent;
use Drupal\package_manager\ValidationResult; use Drupal\package_manager\ValidationResult;
...@@ -413,4 +414,31 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase { ...@@ -413,4 +414,31 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase {
$assert_session->pageTextContainsOnce('Update complete!'); $assert_session->pageTextContainsOnce('Update complete!');
} }
/**
* Tests that the update stage is destroyed if an error occurs during require.
*/
public function testStageDestroyedOnError(): void {
$session = $this->getSession();
$assert_session = $this->assertSession();
$page = $session->getPage();
$this->setCoreVersion('9.8.0');
$this->checkForUpdates();
$this->drupalGet('/admin/modules/automatic-update');
$error = new \Exception('Some Exception');
TestSubscriber1::setException($error, PostRequireEvent::class);
$assert_session->pageTextNotContains(static::$errorsExplanation);
$assert_session->pageTextNotContains(static::$warningsExplanation);
$page->pressButton('Update');
$this->checkForMetaRefresh();
$this->assertUpdateStagedTimes(1);
$assert_session->pageTextContainsOnce('An error has occurred.');
$page->clickLink('the error page');
$assert_session->addressEquals('/admin/modules/automatic-update');
$assert_session->pageTextNotContains('Cannot begin an update because another Composer operation is currently in progress.');
$assert_session->buttonNotExists('Delete existing update');
$assert_session->pageTextContains('Some Exception');
$assert_session->buttonExists('Update');
}
} }
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