diff --git a/src/BatchProcessor.php b/src/BatchProcessor.php index 6e0ac4f158ff283516e67270189b9fa419103875..fbf90ab0156c9f94ed290ee669c60409a851a684 100644 --- a/src/BatchProcessor.php +++ b/src/BatchProcessor.php @@ -96,11 +96,11 @@ class BatchProcessor { * @param array $context * The current context of the batch job. * - * @see \Drupal\automatic_updates\Updater::commit() + * @see \Drupal\automatic_updates\Updater::apply() */ public static function commit(array &$context): void { try { - static::getUpdater()->commit(); + static::getUpdater()->apply(); } catch (\Throwable $e) { static::handleException($e, $context); diff --git a/src/CronUpdater.php b/src/CronUpdater.php index c9392e5af2b9df90435cba7effd3e120fe2ed271..ff111659af69304110996b1706d896b19167d4c3 100644 --- a/src/CronUpdater.php +++ b/src/CronUpdater.php @@ -131,7 +131,7 @@ class CronUpdater implements ContainerInjectionInterface { 'drupal' => $recommended_version, ]); $this->updater->stage(); - $this->updater->commit(); + $this->updater->apply(); $this->updater->clean(); } catch (\Throwable $e) { diff --git a/src/Updater.php b/src/Updater.php index 4df1e6b946c4c0f5c2717fc24e8f4f0900d272fb..cc5daf6f81f63fec6a11decdbc3a0f4372aeaacc 100644 --- a/src/Updater.php +++ b/src/Updater.php @@ -19,7 +19,7 @@ class Updater extends Stage { * * @var string */ - public const STATE_KEY = 'AUTOMATIC_UPDATES_CURRENT'; + protected const STATE_KEY = 'AUTOMATIC_UPDATES_CURRENT'; /** * The state service. @@ -77,7 +77,11 @@ class Updater extends Stage { foreach ($composer->getCorePackageNames() as $package) { $packages[$package] = $project_versions['drupal']; } - $stage_key = $this->createActiveStage($packages); + $stage_key = static::STATE_KEY . microtime(); + $this->state->set(static::STATE_KEY, [ + 'id' => $stage_key, + 'package_versions' => $packages, + ]); $this->create(); return $stage_key; } @@ -107,13 +111,6 @@ class Updater extends Stage { $this->require($requirements); } - /** - * Commits the current update. - */ - public function commit(): void { - $this->apply(); - } - /** * Cleans the current update. */ @@ -122,25 +119,6 @@ class Updater extends Stage { $this->state->delete(static::STATE_KEY); } - /** - * Initializes an active update and returns its ID. - * - * @param string[] $package_versions - * The versions of the packages to stage, keyed by package name. - * - * @return string - * The active update ID. - */ - private function createActiveStage(array $package_versions): string { - $value = static::STATE_KEY . microtime(); - - $this->state->set(static::STATE_KEY, [ - 'id' => $value, - 'package_versions' => $package_versions, - ]); - return $value; - } - /** * {@inheritdoc} */ diff --git a/tests/modules/automatic_updates_test/src/TestController.php b/tests/modules/automatic_updates_test/src/TestController.php index 69308a467d37b439fdaaa251f3d7fb120e249417..d96e56a01fdfa96e13e254cb8f3248ef012904eb 100644 --- a/tests/modules/automatic_updates_test/src/TestController.php +++ b/tests/modules/automatic_updates_test/src/TestController.php @@ -33,7 +33,7 @@ class TestController extends ControllerBase { try { $updater->begin(['drupal' => $to_version]); $updater->stage(); - $updater->commit(); + $updater->apply(); $updater->clean(); $project = (new UpdateRecommender())->getProjectInfo(); diff --git a/tests/src/Kernel/CronUpdaterTest.php b/tests/src/Kernel/CronUpdaterTest.php index d65f5e21db4e5b9cb0b4afa6d5ef3a59e44ce8b9..e31a4f2c40d175b590528c82972eeb92ce42e357 100644 --- a/tests/src/Kernel/CronUpdaterTest.php +++ b/tests/src/Kernel/CronUpdaterTest.php @@ -107,7 +107,7 @@ class CronUpdaterTest extends AutomaticUpdatesKernelTestBase { $updater->begin(['drupal' => '9.8.1'])->shouldBeCalledTimes($will_update); $updater->stage()->shouldBeCalledTimes($will_update); - $updater->commit()->shouldBeCalledTimes($will_update); + $updater->apply()->shouldBeCalledTimes($will_update); $updater->clean()->shouldBeCalledTimes($will_update); $this->container->set('automatic_updates.updater', $updater->reveal());