diff --git a/src/CronUpdateStage.php b/src/CronUpdateStage.php index 8568ba9a4f390b9cc86c48279f7168ec40d80e6a..bd75d4eab0401e292724cd17b3d9d688e1d126d1 100644 --- a/src/CronUpdateStage.php +++ b/src/CronUpdateStage.php @@ -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 diff --git a/tests/src/Kernel/AutomaticUpdatesKernelTestBase.php b/tests/src/Kernel/AutomaticUpdatesKernelTestBase.php index d2afe3b9c803fad500c30c33d40258a4a7e380da..a7832fd96a5c48dd95ed9edc9fe46f4d50915a2a 100644 --- a/tests/src/Kernel/AutomaticUpdatesKernelTestBase.php +++ b/tests/src/Kernel/AutomaticUpdatesKernelTestBase.php @@ -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); } }