Skip to content
Snippets Groups Projects

Issue #3285631: Make it impossible to call CronUpdater::begin() directly

Merged Issue #3285631: Make it impossible to call CronUpdater::begin() directly
All threads resolved!
All threads resolved!
+ 3
3
@@ -96,12 +96,12 @@ class CronUpdater extends Updater {
@@ -96,12 +96,12 @@ class CronUpdater extends Updater {
/**
/**
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public function begin(array $project_versions, ?int $timeout = 300): string {
final public function begin(array $project_versions, ?int $timeout = 300): string {
// Prevent mischievous callers from starting an update even if unattended
// Prevent mischievous callers from starting an update even if unattended
// updates are disabled. To start an update programmatically, use
// updates are disabled. To start an update programmatically, use
// \Drupal\automatic_updates\Updater::begin().
// \Drupal\automatic_updates\Updater::begin().
if ($this->getMode() === static::DISABLED) {
if ($this->getMode() === static::DISABLED) {
throw new \LogicException('Unattended updates are disabled.');
throw new \BadMethodCallException(__METHOD__ . '() cannot be called directly.');
}
}
return parent::begin($project_versions, $timeout);
return parent::begin($project_versions, $timeout);
}
}
@@ -126,7 +126,7 @@ class CronUpdater extends Updater {
@@ -126,7 +126,7 @@ class CronUpdater extends Updater {
// handle any exceptions or validation errors consistently, and destroy the
// handle any exceptions or validation errors consistently, and destroy the
// stage regardless of whether the update succeeds.
// stage regardless of whether the update succeeds.
try {
try {
$this->begin(['drupal' => $target_version], $timeout);
parent::begin(['drupal' => $target_version], $timeout);
$this->stage();
$this->stage();
$this->apply();
$this->apply();
Loading