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

Issue #3354312 by tedbow: Refactor CronUpdateStage::triggerPostApply to make...

Issue #3354312 by tedbow: Refactor CronUpdateStage::triggerPostApply to make easy to override and not use a web request
parent 0b3607a4
No related branches found
No related tags found
No related merge requests found
......@@ -241,26 +241,29 @@ class CronUpdateStage extends UpdateStage {
}
return;
}
$this->triggerPostApply($stage_id, $installed_version, $target_version);
}
/**
* Triggers the post-apply tasks.
*
* @param string $stage_id
* The ID of the current stage.
* @param string $start_version
* The version of Drupal core that started the update.
* @param string $target_version
* The version of Drupal core to which we are updating.
*/
protected function triggerPostApply(string $stage_id, string $start_version, string $target_version): void {
// Perform a subrequest to run ::postApply(), which needs to be done in a
// separate request.
// @see parent::apply()
$url = Url::fromRoute('automatic_updates.cron.post_apply', [
'stage_id' => $stage_id,
'installed_version' => $installed_version,
'installed_version' => $start_version,
'target_version' => $target_version,
'key' => $this->state->get('system.cron_key'),
]);
$this->triggerPostApply($url);
}
/**
* Executes a subrequest to run post-apply tasks.
*
* @param \Drupal\Core\Url $url
* The URL of the post-apply handler.
*/
protected function triggerPostApply(Url $url): void {
$url = $url->setAbsolute()->toString();
// If we're using a single-threaded web server (e.g., the built-in PHP web
......
......@@ -7,7 +7,6 @@ namespace Drupal\Tests\automatic_updates\Kernel;
use Drupal\automatic_updates\CronUpdateStage;
use Drupal\automatic_updates\UpdateStage;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\Url;
use Drupal\Tests\automatic_updates\Traits\ValidationTestTrait;
use Drupal\Tests\package_manager\Kernel\PackageManagerKernelTestBase;
......@@ -107,11 +106,10 @@ class TestCronUpdateStage extends CronUpdateStage {
/**
* {@inheritdoc}
*/
protected function triggerPostApply(Url $url): void {
protected function triggerPostApply(string $stage_id, string $start_version, string $target_version): void {
// Subrequests don't work in kernel tests, so just call the post-apply
// handler directly.
$parameters = $url->getRouteParameters();
$this->handlePostApply($parameters['stage_id'], $parameters['installed_version'], $parameters['target_version']);
$this->handlePostApply($stage_id, $start_version, $target_version);
}
}
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