function install_run_tasks
Same name in other branches
- 7.x includes/install.core.inc \install_run_tasks()
- 9 core/includes/install.core.inc \install_run_tasks()
- 10 core/includes/install.core.inc \install_run_tasks()
- 11.x core/includes/install.core.inc \install_run_tasks()
Runs all tasks for the current installation request.
In the case of an interactive installation, all tasks will be attempted until one is reached that has output which needs to be displayed to the user, or until a page redirect is required. Otherwise, tasks will be attempted until the installation is finished.
Parameters
$install_state: An array of information about the current installation state. This is passed along to each task, so it can be modified if necessary.
callable $callback: (optional) A callback to allow command line processes to update a progress bar. The callback is passed the $install_state variable.
Return value
HTML output from the last completed task.
1 call to install_run_tasks()
- install_drupal in core/
includes/ install.core.inc - Installs Drupal either interactively or via an array of passed-in settings.
File
-
core/
includes/ install.core.inc, line 556
Code
function install_run_tasks(&$install_state, callable $callback = NULL) {
do {
// Obtain a list of tasks to perform. The list of tasks itself can be
// dynamic (e.g., some might be defined by the installation profile,
// which is not necessarily known until the earlier tasks have run),
// so we regenerate the remaining tasks based on the installation state,
// each time through the loop.
$tasks_to_perform = install_tasks_to_perform($install_state);
// Run the first task on the list.
reset($tasks_to_perform);
$task_name = key($tasks_to_perform);
$task = array_shift($tasks_to_perform);
$install_state['active_task'] = $task_name;
$original_parameters = $install_state['parameters'];
$output = install_run_task($task, $install_state);
// Ensure the maintenance theme is initialized. If the install task has
// rebuilt the container the active theme will not be set. This can occur if
// the task has installed a module.
drupal_maintenance_theme();
$install_state['parameters_changed'] = $install_state['parameters'] != $original_parameters;
// Store this task as having been performed during the current request,
// and save it to the database as completed, if we need to and if the
// database is in a state that allows us to do so. Also mark the
// installation as 'done' when we have run out of tasks.
if (!$install_state['task_not_complete']) {
$install_state['tasks_performed'][] = $task_name;
$install_state['installation_finished'] = empty($tasks_to_perform);
if ($task['run'] == INSTALL_TASK_RUN_IF_NOT_COMPLETED || $install_state['installation_finished']) {
\Drupal::state()->set('install_task', $install_state['installation_finished'] ? 'done' : $task_name);
}
}
if ($callback) {
$callback($install_state);
}
// Stop when there are no tasks left. In the case of an interactive
// installation, also stop if we have some output to send to the browser,
// the URL parameters have changed, or an end to the page request was
// specifically called for.
$finished = empty($tasks_to_perform) || $install_state['interactive'] && (isset($output) || $install_state['parameters_changed'] || $install_state['stop_page_request']);
} while (!$finished);
return $output;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.