diff --git a/core/includes/install.inc b/core/includes/install.inc index 41d244a..d78a9c0 100644 --- a/core/includes/install.inc +++ b/core/includes/install.inc @@ -305,10 +305,11 @@ function drupal_verify_profile($install_state) { * functions can be made available while other modules are installed. */ function drupal_install_system() { + // Create tables. + drupal_install_schema('system'); + $system_path = drupal_get_path('module', 'system'); require_once DRUPAL_ROOT . '/' . $system_path . '/system.install'; - module_invoke('system', 'install'); - $system_versions = drupal_get_schema_versions('system'); $system_version = $system_versions ? max($system_versions) : SCHEMA_INSTALLED; db_insert('system') @@ -323,8 +324,19 @@ function drupal_install_system() { 'bootstrap' => 0, )) ->execute(); + + // Clear out module list and hook implementation statics before calling + // system_rebuild_theme_data(). + drupal_static_reset('system_list'); + module_list_reset(); + module_implements_reset(); + system_rebuild_module_data(); + system_rebuild_theme_data(); + config_install_default_config('system'); + + module_invoke('system', 'install'); } /** diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorCronTest.php b/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorCronTest.php index a6c2968..0966937 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorCronTest.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorCronTest.php @@ -22,7 +22,7 @@ class AggregatorCronTest extends AggregatorTestBase { public function testCron() { // Create feed and test basic updating on cron. global $base_url; - $key = config('system.cron')->get('cron_key'); + $key = config('system.cron')->get('key'); $this->createSampleNodes(); $feed = $this->createFeed(); $this->cronRun(); diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php index 0856611..9bc42ee 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php @@ -1384,7 +1384,7 @@ abstract class WebTestBase extends TestBase { * Runs cron in the Drupal installed by Simpletest. */ protected function cronRun() { - $this->drupalGet('cron/' . config('system.cron')->get('cron_key')); + $this->drupalGet('cron/' . config('system.cron')->get('key')); } /** diff --git a/core/modules/system/config/system.cron.yml b/core/modules/system/config/system.cron.yml index 570b70b..4d96e30 100644 --- a/core/modules/system/config/system.cron.yml +++ b/core/modules/system/config/system.cron.yml @@ -1,5 +1,5 @@ -cron_max_threshold: '10800' -cron_safe_threshold: '10800' -cron_threshold_warning: '172800' -cron_threshold_error: '1209600' -cron_key: drupal +key: '' +threshold: + autorun: '10800' + requirements_warning: '172800' + requirements_error: '1209600' 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 601c5a8..3ac2772 100644 --- a/core/modules/system/lib/Drupal/system/Tests/System/CronRunTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/System/CronRunTest.php @@ -38,7 +38,7 @@ class CronRunTest extends WebTestBase { $this->assertResponse(403); // Run cron anonymously with the valid cron key. - $key = config('system.cron')->get('cron_key'); + $key = config('system.cron')->get('key'); $this->drupalGet('cron/' . $key); $this->assertResponse(204); } @@ -56,7 +56,7 @@ class CronRunTest extends WebTestBase { $cron_safe_threshold = 100; variable_set('cron_last', $cron_last); config('system.cron') - ->set('cron_safe_threshold', $cron_safe_threshold) + ->set('threshold.autorun', $cron_safe_threshold) ->save(); $this->drupalGet(''); $this->assertTrue($cron_last == variable_get('cron_last', NULL), t('Cron does not run when the cron threshold is not passed.')); diff --git a/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc index f11f15b..af08514 100644 --- a/core/modules/system/system.admin.inc +++ b/core/modules/system/system.admin.inc @@ -1584,7 +1584,6 @@ function system_site_information_settings_submit($form, &$form_state) { /** * Form builder; Cron form. * - * @see system_settings_form() * @ingroup forms */ function system_cron_settings($form, &$form_state) { @@ -1596,40 +1595,34 @@ function system_cron_settings($form, &$form_state) { '#value' => t('Run cron'), '#submit' => array('system_run_cron_submit'), ); + $status = '

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

'; $form['status'] = array( '#markup' => $status, ); + $form['cron'] = array( '#type' => 'fieldset', ); $form['cron']['cron_safe_threshold'] = array( '#type' => 'select', '#title' => t('Run cron every'), - '#default_value' => config('system.cron')->get('cron_safe_threshold'), + '#default_value' => config('system.cron')->get('threshold.autorun'), '#options' => array(0 => t('Never')) + drupal_map_assoc(array(3600, 10800, 21600, 43200, 86400, 604800), 'format_interval'), ); - // @todo This needs to be reviewed when #1324618 gets in. - $form_state['config']['cron_safe_threshold'] = array( - 'name' => 'system.cron', - 'path' => 'cron_safe_threshold', - ); - $form['submit'] = array('#type' => 'submit', '#value' => t('Save configuration')); - return $form; + return system_config_form($form, $form_state); } /** * Form builder submit handler; Handle submission for cron settings. * * @ingroup forms - * @see system_settings_form() */ function system_cron_settings_submit($form, &$form_state) { config('system.cron') - ->set('cron_safe_threshold', $form_state['values']['cron_safe_threshold']) + ->set('threshold.autorun', $form_state['values']['cron_safe_threshold']) ->save(); - drupal_set_message(t('The configuration options have been saved.')); } /** diff --git a/core/modules/system/system.install b/core/modules/system/system.install index 0605a1d..de0eb31 100644 --- a/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -263,11 +263,11 @@ function system_requirements($phase) { // Report cron status. if ($phase == 'runtime') { - $config = config('system.cron'); + $cron_config = config('system.cron'); // Cron warning threshold defaults to two days. - $threshold_warning = $config->get('cron_threshold_warning'); + $threshold_warning = $cron_config->get('threshold.requirements_warning'); // Cron error threshold defaults to two weeks. - $threshold_error = $config->get('cron_threshold_error'); + $threshold_error = $cron_config->get('threshold.requirements_error'); // Cron configuration help text. $help = $t('For more information, see the online handbook entry for configuring cron jobs.', array('@cron-handbook' => 'http://drupal.org/cron')); @@ -294,7 +294,7 @@ function system_requirements($phase) { } $description .= ' ' . $t('You can run cron manually.', array('@cron' => url('admin/reports/status/run-cron'))); - $description .= '
' . $t('To run cron from outside the site, go to !cron', array('!cron' => url('cron/' . $config->get('cron_key')))); + $description .= '
' . $t('To run cron from outside the site, go to !cron', array('!cron' => url('cron/' . $cron_config->get('key')))); $requirements['cron'] = array( 'title' => $t('Cron maintenance tasks'), @@ -506,21 +506,6 @@ function system_requirements($phase) { * Implements hook_install(). */ function system_install() { - // Create tables. - drupal_install_schema('system'); - $versions = drupal_get_schema_versions('system'); - $version = $versions ? max($versions) : SCHEMA_INSTALLED; - drupal_set_installed_schema_version('system', $version); - - // Clear out module list and hook implementation statics before calling - // system_rebuild_theme_data(). - drupal_static_reset('system_list'); - module_list_reset(); - module_implements_reset(); - - // Load system theme data appropriately. - system_rebuild_theme_data(); - // Enable the default theme. variable_set('theme_default', 'stark'); db_update('system') @@ -532,7 +517,7 @@ function system_install() { // Populate the cron key variable. $cron_key = drupal_hash_base64(drupal_random_bytes(55)); config('system.cron') - ->set('cron_key', $cron_key) + ->set('key', $cron_key) ->save(); } @@ -1904,11 +1889,10 @@ function system_update_8008() { */ function system_update_8009() { update_variables_to_config('system.cron', array( - 'cron_max_threshold' => 'cron_max_threshold', - 'cron_safe_threshold' => 'cron_safe_threshold', - 'cron_threshold_warning' => 'cron_threshold_warning', - 'cron_threshold_error' => 'cron_threshold_error', - 'cron_key' => 'cron_key', + 'cron_key' => 'key', + 'cron_safe_threshold' => 'threshold.autorun', + 'cron_threshold_warning' => 'threshold.requirements_warning', + 'cron_threshold_error' => 'threshold.requirements_error', )); } diff --git a/core/modules/system/system.module b/core/modules/system/system.module index a76e3ae..48a25ec 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -1178,7 +1178,7 @@ function system_cron_page() { * @see system_cron_page(). */ function system_cron_access($key) { - if ($key != config('system.cron')->get('cron_key')) { + if ($key != config('system.cron')->get('key')) { watchdog('cron', 'Cron could not run because an invalid key was used.', array(), WATCHDOG_NOTICE); return FALSE; } @@ -3790,7 +3790,7 @@ function system_run_automated_cron() { // If the site is not fully installed, suppress the automated cron run. // Otherwise it could be triggered prematurely by Ajax requests during // installation. - if (($threshold = config('system.cron')->get('cron_safe_threshold')) > 0 && variable_get('install_task') == 'done') { + if (($threshold = config('system.cron')->get('threshold.autorun')) > 0 && variable_get('install_task') == 'done') { $cron_last = variable_get('cron_last', NULL); if (!isset($cron_last) || (REQUEST_TIME - $cron_last > $threshold)) { drupal_cron_run();