Commit 783d2036 authored by phenaproxima's avatar phenaproxima
Browse files

Merge branch '8.x-2.x' into 3242724-ensure-core-package

parents 567c4864 6240c602
......@@ -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());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment