Skip to content
Snippets Groups Projects
Commit 27373b7c authored by Ted Bowman's avatar Ted Bowman
Browse files

Issue #3375679: CronFrequencyValidator should not check if updates will be run via console

parent c796dde5
No related branches found
No related tags found
2 merge requests!989Issue #3356804 by phenaproxima: Flag a warning during status check if the...,!937Issue #3375679: CronFrequencyValidator should not check if updates will be run via console
...@@ -82,9 +82,11 @@ final class CronFrequencyValidator implements EventSubscriberInterface { ...@@ -82,9 +82,11 @@ final class CronFrequencyValidator implements EventSubscriberInterface {
if (!$event->stage instanceof CronUpdateStage) { if (!$event->stage instanceof CronUpdateStage) {
return; return;
} }
// If automatic updates are disabled during cron, there's nothing we need // If automatic updates are disabled during cron or updates will be run via
// to validate. // the console command, there's nothing we need to validate.
if ($event->stage->getMode() === CronUpdateStage::DISABLED) { $method = $this->configFactory->get('automatic_updates.settings')
->get('unattended.method');
if ($event->stage->getMode() === CronUpdateStage::DISABLED || $method !== 'web') {
return; return;
} }
// If cron is running right now, cron is clearly being run recently enough! // If cron is running right now, cron is clearly being run recently enough!
......
...@@ -35,18 +35,33 @@ class CronFrequencyValidatorTest extends AutomaticUpdatesKernelTestBase { ...@@ -35,18 +35,33 @@ class CronFrequencyValidatorTest extends AutomaticUpdatesKernelTestBase {
} }
/** /**
* Tests that nothing is validated if updates are disabled during cron. * Tests that nothing is validated if not needed.
*/ */
public function testNoValidationIfCronDisabled(): void { public function testNoValidation(): void {
$this->config('automatic_updates.settings')
->set('unattended.level', CronUpdateStage::DISABLED)
->save();
$state = $this->container->get('state'); $state = $this->container->get('state');
$state->delete('system.cron_last'); $state->delete('system.cron_last');
$state->delete('install_time'); $state->delete('install_time');
// If the method is 'web' but cron updates are disabled no validation is
// needed.
$this->config('automatic_updates.settings')
->set('unattended.level', CronUpdateStage::DISABLED)
->set('unattended.method', 'web')
->save();
$this->assertCheckerResultsFromManager([], TRUE); $this->assertCheckerResultsFromManager([], TRUE);
// If cron updates are enabled but the method is 'console' no validation is
// needed.
$this->config('automatic_updates.settings')
->set('unattended.level', CronUpdateStage::ALL)
->set('unattended.method', 'console')
->save();
$this->assertCheckerResultsFromManager([], TRUE);
// If cron updates are enabled and the method is 'web' validation is needed.
$this->config('automatic_updates.settings') $this->config('automatic_updates.settings')
->set('unattended.level', CronUpdateStage::ALL) ->set('unattended.level', CronUpdateStage::ALL)
->set('unattended.method', 'web')
->save(); ->save();
$error = ValidationResult::createError([ $error = ValidationResult::createError([
t('Cron has not run recently. For more information, see the online handbook entry for <a href="https://www.drupal.org/cron">configuring cron jobs</a> to run at least every 3 hours.'), t('Cron has not run recently. For more information, see the online handbook entry for <a href="https://www.drupal.org/cron">configuring cron jobs</a> to run at least every 3 hours.'),
......
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