diff --git a/core/modules/auto_updates/auto_updates.install b/core/modules/auto_updates/auto_updates.install
index 4d3b0aa276..003ddfd995 100644
--- a/core/modules/auto_updates/auto_updates.install
+++ b/core/modules/auto_updates/auto_updates.install
@@ -18,9 +18,6 @@ function auto_updates_requirements($phase) {
/** @var \Drupal\auto_updates\ReadinessChecker\ReadinessCheckerManager $checker_manager */
$checker_manager = \Drupal::service('auto_updates.readiness_checker_manager');
- if (!$checker_manager->isEnabled()) {
- return [];
- }
$requirements['auto_updates_readiness']['title'] = t('Update readiness checks');
$readiness_check_url = Url::fromRoute('auto_updates.update_readiness');
$last_check_timestamp = $checker_manager->getMostRecentRunTime();
diff --git a/core/modules/auto_updates/auto_updates.links.menu.yml b/core/modules/auto_updates/auto_updates.links.menu.yml
index 4505736268..ed925d597b 100644
--- a/core/modules/auto_updates/auto_updates.links.menu.yml
+++ b/core/modules/auto_updates/auto_updates.links.menu.yml
@@ -1,5 +1,6 @@
-auto_updates.settings:
- title: 'Automatic updates'
- route_name: auto_updates.settings
- description: 'Configure automatic update settings.'
- parent: system.admin_config_system
+
+auto_updates.status:
+ title: 'Automatic updates status'
+ route_name: auto_updates.status
+ description: "Get a status report on your site's readiness for automatic updates."
+ parent: system.admin_reports
diff --git a/core/modules/auto_updates/auto_updates.routing.yml b/core/modules/auto_updates/auto_updates.routing.yml
index eba68de6bf..b9ec3d6efc 100644
--- a/core/modules/auto_updates/auto_updates.routing.yml
+++ b/core/modules/auto_updates/auto_updates.routing.yml
@@ -1,19 +1,18 @@
-auto_updates.settings:
- path: '/admin/config/auto_updates'
+auto_updates.status:
+ path: '/admin/reports/auto_updates'
defaults:
- _form: '\Drupal\auto_updates\Form\SettingsForm'
- _title: 'Automatic Updates'
+ _controller: '\Drupal\auto_updates\Controller\ReadinessCheckerController::status'
+ _title: 'Update readiness status'
requirements:
_permission: 'administer software updates'
options:
_admin_route: TRUE
auto_updates.update_readiness:
- path: '/admin/config/auto_updates/readiness'
+ path: '/admin/reports/auto_updates/readiness'
defaults:
_controller: '\Drupal\auto_updates\Controller\ReadinessCheckerController::run'
_title: 'Update readiness checking'
requirements:
_permission: 'administer software updates'
- _custom_access: '\Drupal\auto_updates\Controller\ReadinessCheckerController::access'
options:
_admin_route: TRUE
diff --git a/core/modules/auto_updates/config/install/auto_updates.settings.yml b/core/modules/auto_updates/config/install/auto_updates.settings.yml
deleted file mode 100644
index de0b8d7d73..0000000000
--- a/core/modules/auto_updates/config/install/auto_updates.settings.yml
+++ /dev/null
@@ -1 +0,0 @@
-enable_readiness_checks: true
diff --git a/core/modules/auto_updates/config/schema/auto_updates.schema.yml b/core/modules/auto_updates/config/schema/auto_updates.schema.yml
deleted file mode 100644
index 047a224f44..0000000000
--- a/core/modules/auto_updates/config/schema/auto_updates.schema.yml
+++ /dev/null
@@ -1,7 +0,0 @@
-auto_updates.settings:
- type: config_object
- label: 'Automatic updates settings'
- mapping:
- enable_readiness_checks:
- type: boolean
- label: 'Enable readiness checks'
diff --git a/core/modules/auto_updates/src/Controller/ReadinessCheckerController.php b/core/modules/auto_updates/src/Controller/ReadinessCheckerController.php
index 1dc90b43ef..cf133e6d17 100644
--- a/core/modules/auto_updates/src/Controller/ReadinessCheckerController.php
+++ b/core/modules/auto_updates/src/Controller/ReadinessCheckerController.php
@@ -3,10 +3,10 @@
namespace Drupal\auto_updates\Controller;
use Drupal\auto_updates\ReadinessChecker\ReadinessCheckerManager;
-use Drupal\Core\Access\AccessResult;
-use Drupal\Core\Access\AccessResultInterface;
use Drupal\Core\Controller\ControllerBase;
+use Drupal\Core\Datetime\DateFormatter;
use Drupal\Core\StringTranslation\TranslationInterface;
+use Drupal\Core\Url;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
@@ -25,6 +25,13 @@ class ReadinessCheckerController extends ControllerBase {
*/
protected $checkerManager;
+ /**
+ * The date formatter.
+ *
+ * @var \Drupal\Core\Datetime\DateFormatterInterface
+ */
+ protected $dateFormatter;
+
/**
* ReadinessCheckerController constructor.
*
@@ -32,10 +39,13 @@ class ReadinessCheckerController extends ControllerBase {
* The readiness checker manager.
* @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation
* The string translation service.
+ * @param \Drupal\Core\Datetime\DateFormatter $date_formatter
+ * The date formatter service.
*/
- public function __construct(ReadinessCheckerManager $checker_manager, TranslationInterface $string_translation) {
+ public function __construct(ReadinessCheckerManager $checker_manager, TranslationInterface $string_translation, DateFormatter $date_formatter) {
$this->checkerManager = $checker_manager;
$this->setStringTranslation($string_translation);
+ $this->dateFormatter = $date_formatter;
}
/**
@@ -44,10 +54,49 @@ public function __construct(ReadinessCheckerManager $checker_manager, Translatio
public static function create(ContainerInterface $container) {
return new static(
$container->get('auto_updates.readiness_checker_manager'),
- $container->get('string_translation')
+ $container->get('string_translation'),
+ $container->get('date.formatter')
);
}
+ /**
+ * Displays a status report for automatic update readiness.
+ *
+ * @return mixed[]
+ * The status report render array.
+ */
+ public function status() {
+ $last_check_timestamp = $this->checkerManager->getMostRecentRunTime();
+
+ $readiness_messages = $last_check_timestamp === NULL ?
+ $this->t('Readiness checks have never been run.')
+ : $this->t('Readiness checks were last run @time ago.', ['@time' => $this->dateFormatter->formatTimeDiffSince($last_check_timestamp)]);
+ $return['last_run']['#markup'] = $readiness_messages . ' ' .
+ $this->t('Manually run the readiness checks.',
+ [
+ ':url' => Url::fromRoute('auto_updates.update_readiness')->toString(),
+ ]
+ );
+ $error_results = $this->checkerManager->getErrors();
+ $warning_results = $this->checkerManager->getWarnings();
+ $checker_results = array_merge($error_results, $warning_results);
+ if ($checker_results) {
+ $return['status']['#markup'] = $this->formatPlural(count($checker_results), '@count check failed:', '@count checks failed:');
+ $return['results'] = [
+ '#theme' => 'item_list',
+ '#items' => $checker_results,
+ ];
+ }
+ else {
+ $return['status'] = [
+ '#type' => 'container',
+ '#markup' => $this->t('Your site is ready for automatic updates.'),
+ ];
+ }
+
+ return $return;
+ }
+
/**
* Run the readiness checkers.
*
@@ -60,17 +109,7 @@ public function run(): RedirectResponse {
// https://www.drupal.org/node/3168405.
$this->messenger()->addStatus($this->t('No issues found. Your site is ready for automatic updates'));
}
- return $this->redirect('auto_updates.settings');
- }
-
- /**
- * Checks access based on whether the readiness checkers are enabled.
- *
- * @return \Drupal\Core\Access\AccessResultInterface
- * The access result.
- */
- public function access(): AccessResultInterface {
- return AccessResult::allowedIf($this->checkerManager->isEnabled());
+ return $this->redirect('auto_updates.status');
}
}
diff --git a/core/modules/auto_updates/src/Form/SettingsForm.php b/core/modules/auto_updates/src/Form/SettingsForm.php
deleted file mode 100644
index 07530515fd..0000000000
--- a/core/modules/auto_updates/src/Form/SettingsForm.php
+++ /dev/null
@@ -1,92 +0,0 @@
-checkerManager = $container->get('auto_updates.readiness_checker_manager');
- $instance->dateFormatter = $container->get('date.formatter');
- return $instance;
- }
-
- /**
- * {@inheritdoc}
- */
- protected function getEditableConfigNames() {
- return [
- 'auto_updates.settings',
- ];
- }
-
- /**
- * {@inheritdoc}
- */
- public function getFormId() {
- return 'auto_updates_settings_form';
- }
-
- /**
- * {@inheritdoc}
- */
- public function buildForm(array $form, FormStateInterface $form_state) {
- $config = $this->config('auto_updates.settings');
- $last_check_timestamp = $this->checkerManager->getMostRecentRunTime();
- $form['enable_readiness_checks'] = [
- '#type' => 'checkbox',
- '#title' => $this->t('Check the readiness of automatically updating the site.'),
- '#default_value' => $config->get('enable_readiness_checks'),
- ];
- if ($this->checkerManager->isEnabled()) {
- $readiness_messages = $last_check_timestamp === NULL ?
- $this->t('Readiness checks have never been run.')
- : $this->t('Readiness checks were last run @time ago.', ['@time' => $this->dateFormatter->formatTimeDiffSince($last_check_timestamp)]);
- $form['enable_readiness_checks']['#description'] = $readiness_messages . ' ' . $this->t('Manually run the readiness checks.', [
- ':url' => Url::fromRoute('auto_updates.update_readiness')->toString(),
- ]);
- }
- return parent::buildForm($form, $form_state);
- }
-
- /**
- * {@inheritdoc}
- */
- public function submitForm(array &$form, FormStateInterface $form_state) {
- parent::submitForm($form, $form_state);
- $form_state->cleanValues();
- $config = $this->config('auto_updates.settings');
- foreach ($form_state->getValues() as $key => $value) {
- $config->set($key, $value);
- }
- $config->save();
- }
-
-}
diff --git a/core/modules/auto_updates/src/ReadinessChecker/ReadinessCheckerManager.php b/core/modules/auto_updates/src/ReadinessChecker/ReadinessCheckerManager.php
index 516e958536..cf745b23fe 100644
--- a/core/modules/auto_updates/src/ReadinessChecker/ReadinessCheckerManager.php
+++ b/core/modules/auto_updates/src/ReadinessChecker/ReadinessCheckerManager.php
@@ -95,10 +95,6 @@ public function addChecker(ReadinessCheckerInterface $checker, $priority = 0): R
* for the category.
*/
protected function run(bool $refresh = FALSE): array {
- $messages_by_category = ['errors' => [], 'warnings' => []];
- if (!$this->isEnabled()) {
- return $messages_by_category;
- }
if ($refresh) {
$this->keyValueExpirable->delete('readiness_check_results');
}
@@ -113,6 +109,7 @@ protected function run(bool $refresh = FALSE): array {
}
$sorted_checkers = $this->getSortedCheckers();
+ $messages_by_category = ['errors' => [], 'warnings' => []];
foreach ($sorted_checkers as $checker) {
$messages_by_category['errors'] = array_merge($messages_by_category['errors'], $checker->getErrors());
$messages_by_category['warnings'] = array_merge($messages_by_category['warnings'], $checker->getWarnings());
@@ -141,16 +138,6 @@ public function getMostRecentRunTime(): int {
return $this->keyValueExpirable->get('readiness_check_timestamp');
}
- /**
- * Determines if readiness checks are enabled.
- *
- * @return bool
- * TRUE if enabled, otherwise FALSE.
- */
- public function isEnabled(): bool {
- return $this->configFactory->get('auto_updates.settings')->get('enable_readiness_checks');
- }
-
/**
* Sorts checkers according to priority.
*
diff --git a/core/modules/auto_updates/tests/src/Functional/ReadinessCheckerTest.php b/core/modules/auto_updates/tests/src/Functional/ReadinessCheckerTest.php
index d4e340bc2b..932d930967 100644
--- a/core/modules/auto_updates/tests/src/Functional/ReadinessCheckerTest.php
+++ b/core/modules/auto_updates/tests/src/Functional/ReadinessCheckerTest.php
@@ -90,8 +90,7 @@ public function testReadinessChecksStatusReport():void {
// @todo If coming from the status report page should you be redirected there?
// This is how 'Run cron' works.
$assert->statusCodeEquals(200);
- $assert->addressEquals('/admin/config/auto_updates');
- $assert->checkboxChecked('enable_readiness_checks');
+ $assert->addressEquals('/admin/reports/auto_updates');
$assert->pageTextNotContains('Access denied');
$assert->pageTextContains('Your site is currently failing readiness checks for automatic updates. It cannot be automatically updated until further action is performed.');
$assert->pageTextContains('OMG 🚒. Your server is on 🔥!');
@@ -106,36 +105,6 @@ public function testReadinessChecksStatusReport():void {
$this->drupalGet('admin/reports/status');
$this->assertReadinessReportMatches('1 check failed: OMG 🚒. Your server is on 🔥!');
- // Disable readiness checks.
- $this->drupalLogin($this->checkerRunnerUser);
- $this->drupalGet('admin/config/auto_updates');
- $page->uncheckField('enable_readiness_checks');
- $page->pressButton('Save configuration');
-
- // Confirm that when readiness checkers are disabled no information on the
- // last run is displayed.
- $assert->pageTextNotContains('Readiness checks have never been run.');
- $assert->pageTextNotContains('Readiness checks were last run');
- $assert->pageTextNotContains('run the readiness checks');
-
- // Confirm that access is denied when manually going to the readiness
- // checker controller.
- $this->drupalGet('admin/config/auto_updates/readiness');
- $assert->statusCodeEquals(403);
- $assert->pageTextContains('Access denied');
-
- $this->drupalGet('admin/reports/status');
- $assert->pageTextNotContains('Update readiness checks');
-
- // Re-enable readiness checks.
- $this->drupalGet('admin/config/auto_updates');
- $page->checkField('enable_readiness_checks');
- $page->pressButton('Save configuration');
-
- // Confirm that the last message displayed is displayed again.
- $this->drupalGet('admin/reports/status');
- $this->assertReadinessReportMatches('1 check failed: OMG 🚒. Your server is on 🔥!');
-
$this->setTestMessages(['OMG 🔌. Some one unplugged the server! How is this site even running?']);
/** @var \Drupal\Core\KeyValueStore\KeyValueStoreInterface $keyValue */
$keyValue = $this->container->get('keyvalue.expirable')->get('auto_updates');