protected function DbUpdateController::results in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/src/Controller/DbUpdateController.php \Drupal\system\Controller\DbUpdateController::results()
Displays results of the update script with any accompanying errors.
Parameters
\Symfony\Component\HttpFoundation\Request $request: The current request.
Return value
array A render array.
1 call to DbUpdateController::results()
- DbUpdateController::handle in core/
modules/ system/ src/ Controller/ DbUpdateController.php - Returns a database update page.
File
- core/
modules/ system/ src/ Controller/ DbUpdateController.php, line 397 - Contains \Drupal\system\Controller\DbUpdateController.
Class
- DbUpdateController
- Controller routines for database update routes.
Namespace
Drupal\system\ControllerCode
protected function results(Request $request) {
// @todo Simplify with https://www.drupal.org/node/2548095
$base_url = str_replace('/update.php', '', $request
->getBaseUrl());
// Report end result.
$dblog_exists = $this->moduleHandler
->moduleExists('dblog');
if ($dblog_exists && $this->account
->hasPermission('access site reports')) {
$log_message = $this
->t('All errors have been <a href=":url">logged</a>.', array(
':url' => Url::fromRoute('dblog.overview')
->setOption('base_url', $base_url)
->toString(TRUE)
->getGeneratedUrl(),
));
}
else {
$log_message = $this
->t('All errors have been logged.');
}
if (!empty($_SESSION['update_success'])) {
$message = '<p>' . $this
->t('Updates were attempted. If you see no failures below, you may proceed happily back to your <a href=":url">site</a>. Otherwise, you may need to update your database manually.', array(
':url' => Url::fromRoute('<front>')
->setOption('base_url', $base_url)
->toString(TRUE)
->getGeneratedUrl(),
)) . ' ' . $log_message . '</p>';
}
else {
$last = reset($_SESSION['updates_remaining']);
list($module, $version) = array_pop($last);
$message = '<p class="error">' . $this
->t('The update process was aborted prematurely while running <strong>update #@version in @module.module</strong>.', array(
'@version' => $version,
'@module' => $module,
)) . ' ' . $log_message;
if ($dblog_exists) {
$message .= ' ' . $this
->t('You may need to check the <code>watchdog</code> database table manually.');
}
$message .= '</p>';
}
if (Settings::get('update_free_access')) {
$message .= '<p>' . $this
->t("<strong>Reminder: don't forget to set the <code>\$settings['update_free_access']</code> value in your <code>settings.php</code> file back to <code>FALSE</code>.</strong>") . '</p>';
}
$build['message'] = array(
'#markup' => $message,
);
$build['links'] = array(
'#theme' => 'links',
'#links' => $this
->helpfulLinks($request),
);
// Output a list of info messages.
if (!empty($_SESSION['update_results'])) {
$all_messages = array();
foreach ($_SESSION['update_results'] as $module => $updates) {
if ($module != '#abort') {
$module_has_message = FALSE;
$info_messages = array();
foreach ($updates as $name => $queries) {
$messages = array();
foreach ($queries as $query) {
// If there is no message for this update, don't show anything.
if (empty($query['query'])) {
continue;
}
if ($query['success']) {
$messages[] = array(
'#wrapper_attributes' => array(
'class' => array(
'success',
),
),
'#markup' => $query['query'],
);
}
else {
$messages[] = array(
'#wrapper_attributes' => array(
'class' => array(
'failure',
),
),
'#markup' => '<strong>' . $this
->t('Failed:') . '</strong> ' . $query['query'],
);
}
}
if ($messages) {
$module_has_message = TRUE;
if (is_numeric($name)) {
$title = $this
->t('Update #@count', [
'@count' => $name,
]);
}
else {
$title = $this
->t('Update @name', [
'@name' => trim($name, '_'),
]);
}
$info_messages[] = array(
'#theme' => 'item_list',
'#items' => $messages,
'#title' => $title,
);
}
}
// If there were any messages then prefix them with the module name
// and add it to the global message list.
if ($module_has_message) {
$all_messages[] = array(
'#type' => 'container',
'#prefix' => '<h3>' . $this
->t('@module module', array(
'@module' => $module,
)) . '</h3>',
'#children' => $info_messages,
);
}
}
}
if ($all_messages) {
$build['query_messages'] = array(
'#type' => 'container',
'#children' => $all_messages,
'#attributes' => array(
'class' => array(
'update-results',
),
),
'#prefix' => '<h2>' . $this
->t('The following updates returned messages:') . '</h2>',
);
}
}
unset($_SESSION['update_results']);
unset($_SESSION['update_success']);
unset($_SESSION['update_ignore_warnings']);
return $build;
}