diff --git a/core/modules/auto_updates/auto_updates.install b/core/modules/auto_updates/auto_updates.install
index ff841b48a5..600babcf92 100644
--- a/core/modules/auto_updates/auto_updates.install
+++ b/core/modules/auto_updates/auto_updates.install
@@ -27,21 +27,21 @@ function auto_updates_requirements($phase) {
$last_check_timestamp = $checker_manager->getTimestamp();
if ($last_check_timestamp === NULL) {
$requirements['auto_updates_readiness']['severity'] = REQUIREMENT_ERROR;
- $requirements['auto_updates_readiness']['value'] = t('Your site has never checked if it is ready to apply automatic updates.', ['@readiness_checks' => 'https://www.drupal.org/docs/8/update/automatic-updates#readiness-checks']);
+ $requirements['auto_updates_readiness']['value'] = t('Your site has never checked if it is ready to apply automatic updates.', [':readiness_checks' => 'https://www.drupal.org/docs/8/update/automatic-updates#readiness-checks']);
if ($readiness_check->access()) {
- $requirements['auto_updates_readiness']['description'] = t('Run readiness checks manually.', [
- '@link' => $readiness_check->toString(),
+ $requirements['auto_updates_readiness']['description'] = t('Run readiness checks manually.', [
+ ':link' => $readiness_check->toString(),
]);
}
}
elseif (!$checker_manager->hasRunRecently()) {
$requirements['auto_updates_readiness']['severity'] = REQUIREMENT_ERROR;
$time_ago = \Drupal::service('date.formatter')->formatTimeDiffSince($last_check_timestamp);
- $requirements['auto_updates_readiness']['value'] = t('Your site has not recently checked if it is ready to apply automatic updates.', ['@readiness_checks' => 'https://www.drupal.org/docs/8/update/automatic-updates#readiness-checks']);
+ $requirements['auto_updates_readiness']['value'] = t('Your site has not recently checked if it is ready to apply automatic updates.', [':readiness_checks' => 'https://www.drupal.org/docs/8/update/automatic-updates#readiness-checks']);
if ($readiness_check->access()) {
- $requirements['auto_updates_readiness']['description'] = t('Readiness checks were last run @time ago. Run readiness checks manually.', [
+ $requirements['auto_updates_readiness']['description'] = t('Readiness checks were last run @time ago. Run readiness checks manually.', [
'@time' => $time_ago,
- '@link' => $readiness_check->toString(),
+ ':link' => $readiness_check->toString(),
]);
}
else {
@@ -74,5 +74,7 @@ function auto_updates_requirements($phase) {
* Implements hook_install().
*/
function auto_updates_install($is_syncing) {
- \Drupal::service('auto_updates.readiness_checker_manager')->run();
+ /** @var \Drupal\auto_updates\ReadinessChecker\ReadinessCheckerManagerInterface $checker_manager */
+ $checker_manager = \Drupal::service('auto_updates.readiness_checker_manager');
+ $checker_manager->run();
}
diff --git a/core/modules/auto_updates/src/Form/SettingsForm.php b/core/modules/auto_updates/src/Form/SettingsForm.php
index 5899963879..96f634dfcb 100644
--- a/core/modules/auto_updates/src/Form/SettingsForm.php
+++ b/core/modules/auto_updates/src/Form/SettingsForm.php
@@ -57,15 +57,8 @@ public function getFormId() {
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this->config('auto_updates.settings');
-
- $form['readiness'] = [
- '#type' => 'details',
- '#title' => $this->t('Readiness checks'),
- '#open' => TRUE,
- ];
-
$last_check_timestamp = $this->checkerManager->getTimestamp();
- $form['readiness']['enable_readiness_checks'] = [
+ $form['enable_readiness_checks'] = [
'#type' => 'checkbox',
'#title' => $this->t('Check the readiness of automatically updating the site.'),
'#default_value' => $config->get('enable_readiness_checks'),
@@ -74,7 +67,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
$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['readiness']['enable_readiness_checks']['#description'] = $readiness_messages . ' ' . $this->t('Manually run the readiness checks.', [
+ $form['enable_readiness_checks']['#description'] = $readiness_messages . ' ' . $this->t('Manually run the readiness checks.', [
':url' => Url::fromRoute('auto_updates.update_readiness')->toString(),
]);
}
diff --git a/core/modules/auto_updates/src/ReadinessChecker/DiskSpace.php b/core/modules/auto_updates/src/ReadinessChecker/DiskSpace.php
index e79d04f245..ea5a25c831 100644
--- a/core/modules/auto_updates/src/ReadinessChecker/DiskSpace.php
+++ b/core/modules/auto_updates/src/ReadinessChecker/DiskSpace.php
@@ -5,7 +5,7 @@
use Drupal\Component\FileSystem\FileSystem as FileSystemComponent;
/**
- * The disk space readiness checker.
+ * A readiness checker that ensures there is enough disk space for updates.
*/
class DiskSpace extends FileSystemBase {
@@ -26,16 +26,6 @@ class DiskSpace extends FileSystemBase {
* {@inheritdoc}
*/
protected function doCheck(): array {
- return $this->diskSpaceCheck();
- }
-
- /**
- * Check if the filesystem has sufficient disk space.
- *
- * @return \Drupal\Core\StringTranslation\TranslatableMarkup[]
- * An array of translatable strings if there is not sufficient space.
- */
- protected function diskSpaceCheck(): array {
$messages = [];
$minimum_megabytes = static::MINIMUM_DISK_SPACE / static::MEGABYTE_DIVISOR;
if (!$this->areSameLogicalDisk($this->getRootPath(), $this->getVendorPath())) {
diff --git a/core/modules/auto_updates/src/ReadinessChecker/FileSystemBase.php b/core/modules/auto_updates/src/ReadinessChecker/FileSystemBase.php
index 3a25a35f0d..1a6fb8f1d5 100644
--- a/core/modules/auto_updates/src/ReadinessChecker/FileSystemBase.php
+++ b/core/modules/auto_updates/src/ReadinessChecker/FileSystemBase.php
@@ -35,7 +35,7 @@ public function run(): array {
if (!file_exists(implode(DIRECTORY_SEPARATOR, [$this->getRootPath(), 'core', 'core.api.php']))) {
$messages[] = $this->t('The web root could not be located.');
}
- if (!is_dir($this->getVendorPath())) {
+ if (!file_exists(implode(DIRECTORY_SEPARATOR, [$this->getVendorPath(), 'autoload.php']))) {
$messages[] = $this->t('Vendor folder "@vendor" is not a valid directory. Alternate vendor folder locations are not currently supported.', [
'@vendor' => $this->getVendorPath(),
]);
diff --git a/core/modules/auto_updates/src/ReadinessChecker/ReadinessCheckerManager.php b/core/modules/auto_updates/src/ReadinessChecker/ReadinessCheckerManager.php
index c7d17c23f5..f77076a6af 100644
--- a/core/modules/auto_updates/src/ReadinessChecker/ReadinessCheckerManager.php
+++ b/core/modules/auto_updates/src/ReadinessChecker/ReadinessCheckerManager.php
@@ -7,7 +7,7 @@
use Drupal\Core\KeyValueStore\KeyValueFactoryInterface;
/**
- * Defines a chained readiness checker implementation combining multiple checks.
+ * Defines a manager to run readiness checkers.
*/
class ReadinessCheckerManager implements ReadinessCheckerManagerInterface {
diff --git a/core/modules/auto_updates/tests/src/Functional/ReadinessCheckerTest.php b/core/modules/auto_updates/tests/src/Functional/ReadinessCheckerTest.php
index 248d7b0e81..44a0e09c6e 100644
--- a/core/modules/auto_updates/tests/src/Functional/ReadinessCheckerTest.php
+++ b/core/modules/auto_updates/tests/src/Functional/ReadinessCheckerTest.php
@@ -21,14 +21,14 @@ class ReadinessCheckerTest extends BrowserTestBase {
/**
* A user who can view the status report.
*
- * @var bool|\Drupal\user\Entity\User
+ * @var \Drupal\user\Entity\User
*/
protected $reportViewerUser;
/**
* A user how can view the status report and run readiness checkers.
*
- * @var bool|\Drupal\user\Entity\User
+ * @var \Drupal\user\Entity\User
*/
protected $checkerRunnerUser;
@@ -53,16 +53,20 @@ public function testReadinessChecksStatusReport() {
$assert = $this->assertSession();
$page = $this->getSession()->getPage();
+ // Disable automated_cron before installing auto_updates. This ensures we
+ // are testing that auto_updates runs the checkers when the module itself
+ // is installed and they weren't run on cron.
$this->container->get('module_installer')->uninstall(['automated_cron']);
$this->container->get('module_installer')->install(['auto_updates', 'auto_updates_test']);
// If the site is ready for updates, the users will see the same output
// regardless of whether the user has permission to run updates.
- foreach ([$this->reportViewerUser, $this->checkerRunnerUser] as $user) {
- $this->drupalLogin($user);
- $this->drupalGet('admin/reports/status');
- $this->assertReadinessReportMatches('Your site is ready for automatic updates.');
- }
+ $this->drupalLogin($this->reportViewerUser);
+ $this->drupalGet('admin/reports/status');
+ $this->assertReadinessReportMatches('Your site is ready for automatic updates.');
+ $this->drupalLogin($this->checkerRunnerUser);
+ $this->drupalGet('admin/reports/status');
+ $this->assertReadinessReportMatches('Your site is ready for automatic updates.');
// Confirm a user without the permission to run readiness checks does not
// have a link to run the checks when the checks need to be run again.
@@ -90,14 +94,15 @@ public function testReadinessChecksStatusReport() {
$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 🔥!');
- foreach ([$this->reportViewerUser, $this->checkerRunnerUser] as $user) {
- $this->drupalLogin($user);
- // Confirm the error is displayed on the status report page.
- $this->drupalGet('admin/reports/status');
- $this->assertReadinessReportMatches('1 check failed: OMG 🚒. Your server is on 🔥!');
- // @todo Should we always show when the checks were last run and a link to
- // run when there is an error?
- }
+ // Confirm the error is displayed on the status report page.
+ $this->drupalGet('admin/reports/status');
+ $this->assertReadinessReportMatches('1 check failed: OMG 🚒. Your server is on 🔥!');
+ // @todo Should we always show when the checks were last run and a link to
+ // run when there is an error?
+ // Confirm a user without permission to run the checks sees the same error.
+ $this->drupalLogin($this->reportViewerUser);
+ $this->drupalGet('admin/reports/status');
+ $this->assertReadinessReportMatches('1 check failed: OMG 🚒. Your server is on 🔥!');
// Disable readiness checks.
$this->drupalLogin($this->checkerRunnerUser);
@@ -109,7 +114,7 @@ public function testReadinessChecksStatusReport() {
// 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');
+ $assert->pageTextNotContains('run the readiness checks');
// Confirm that access is denied when manually going to the readiness
// checker controller.
@@ -153,7 +158,7 @@ public function testReadinessCheckAfterInstall() {
// Confirm that installing a module that does not provide a new checker does
// not run the checkers on install.
$this->container->get('state')->set(TestChecker::STATE_KEY, 'Security has been compromised. "pass123" was a bad password!');
- $this->container->get('module_installer')->install(['color']);
+ $this->container->get('module_installer')->install(['help']);
$this->drupalGet('admin/reports/status');
// Confirm that new checker message is not displayed because the checker was
// not run again.