diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index 17e2a66..bcdb1b9 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -439,7 +439,7 @@ function install_run_tasks(&$install_state) { $install_state['tasks_performed'][] = $task_name; $install_state['installation_finished'] = empty($tasks_to_perform); if ($install_state['database_tables_exist'] && ($task['run'] == INSTALL_TASK_RUN_IF_NOT_COMPLETED || $install_state['installation_finished'])) { - variable_set('install_task', $install_state['installation_finished'] ? 'done' : $task_name); + state()->set('install_task', $install_state['installation_finished'] ? 'done' : $task_name); } } // Stop when there are no tasks left. In the case of an interactive @@ -512,7 +512,7 @@ function install_run_task($task, &$install_state) { elseif ($task['type'] == 'batch') { // Start a new batch based on the task function, if one is not running // already. - $current_batch = variable_get('install_current_batch'); + $current_batch = state()->get('install_current_batch'); if (!$install_state['interactive'] || !$current_batch) { $batch = $function($install_state); if (empty($batch)) { @@ -525,7 +525,7 @@ function install_run_task($task, &$install_state) { // task is currently running. Otherwise, we need to make sure the batch // will complete in one page request. if ($install_state['interactive']) { - variable_set('install_current_batch', $function); + state()->set('install_current_batch', $function); } else { $batch =& batch_get(); @@ -554,7 +554,7 @@ function install_run_task($task, &$install_state) { // longer requesting a batch ID. if ($output === FALSE) { // Return nothing so the next task will run in the same request. - variable_del('install_current_batch'); + state()->delete('install_current_batch'); return; } else { @@ -921,16 +921,8 @@ function install_base_system(&$install_state) { * is already installed. */ function install_verify_completed_task() { - try { - if ($result = db_query("SELECT value FROM {variable} WHERE name = :name", array('name' => 'install_task'))) { - $task = unserialize($result->fetchField()); - } - } - // Do not trigger an error if the database query fails, since the database - // might not be set up yet. - catch (Exception $e) { - } - if (isset($task)) { + $task = state()->get('install_task'); + if ($task) { if ($task == 'done') { throw new Exception(install_already_done_error()); } @@ -2002,5 +1994,5 @@ function install_configure_form_submit($form, &$form_state) { user_login_finalize(); // Record when this install ran. - variable_set('install_time', $_SERVER['REQUEST_TIME']); + state()->set('install_time', $_SERVER['REQUEST_TIME']); } diff --git a/core/modules/system/system.install b/core/modules/system/system.install index 3790f2b..be03ab6 100644 --- a/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -274,7 +274,7 @@ function system_requirements($phase) { // Determine when cron last ran. $cron_last = variable_get('cron_last'); if (!is_numeric($cron_last)) { - $cron_last = variable_get('install_time', 0); + $cron_last = state()->get('install_time') ?: 0; } // Determine severity based on time since cron last ran. @@ -1976,6 +1976,20 @@ function system_update_8021() { } /** + * Convert install_task and install_time variables to state api values. + */ +function system_update_8022() { + $variables = array('install_task', 'install_time'); + + foreach ($variables as $variable) { + if ($value = update_variable_get($variable, FALSE)) { + state()->set($variable, $value); + } + update_variable_del($variable); + } +} + +/** * @} End of "defgroup updates-7.x-to-8.x". * The next series of updates should start at 9000. */ diff --git a/core/modules/system/system.module b/core/modules/system/system.module index bfa91db..5e75219 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -3709,7 +3709,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('threshold.autorun')) > 0 && variable_get('install_task') == 'done') { + if (($threshold = config('system.cron')->get('threshold.autorun')) > 0 && state()->get('install_task') == 'done') { $cron_last = variable_get('cron_last', NULL); if (!isset($cron_last) || (REQUEST_TIME - $cron_last > $threshold)) { drupal_cron_run();