diff --git a/core/modules/system/lib/Drupal/system/Tests/System/CronRunTest.php b/core/modules/system/lib/Drupal/system/Tests/System/CronRunTest.php index e3c29b7..5def452 100644 --- a/core/modules/system/lib/Drupal/system/Tests/System/CronRunTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/System/CronRunTest.php @@ -98,4 +98,17 @@ function testCronExceptions() { $result = state()->get('common_test.cron'); $this->assertEqual($result, 'success', 'Cron correctly handles exceptions thrown during hook_cron() invocations.'); } + + /** + * Make sure the cron UI reads from the state storage. + */ + function testCronUI() { + $admin_user = $this->drupalCreateUser(array('administer site configuration')); + $this->drupalLogin($admin_user); + $this->drupalGet('admin/config/system/cron'); + // Don't use REQUEST to calculate the exact time, because that will + // fail randomly. Look for the word 'years', because without a timestamp, + // the time will start at 1 January 1970. + $this->assertNoText('years'); + } } diff --git a/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc index 708854f..d08c4ce 100644 --- a/core/modules/system/system.admin.inc +++ b/core/modules/system/system.admin.inc @@ -1508,7 +1508,7 @@ function system_cron_settings($form, &$form_state) { '#submit' => array('system_run_cron_submit'), ); - $status = '

' . t('Last run: %cron-last ago.', array('%cron-last' => format_interval(REQUEST_TIME - variable_get('cron_last')),)) . '

'; + $status = '

' . t('Last run: %cron-last ago.', array('%cron-last' => format_interval(REQUEST_TIME - state()->get('system.cron_last')))) . '

'; $form['status'] = array( '#markup' => $status, );