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

Issue #3248527 by phenaproxima: Clean up Updater

parent acc33a18
No related branches found
No related tags found
No related merge requests found
......@@ -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);
......
......@@ -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) {
......
......@@ -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}
*/
......
......@@ -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();
......
......@@ -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());
......
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