Commit 229872b3 authored by webchick's avatar webchick

Issue #1951068 by alexpott, chx, BTMash: Fixed install.php error reporting is broken.

parent 58be1ccf
......@@ -153,7 +153,7 @@ function _drupal_render_exception_safe($exception) {
* TRUE if an error should be displayed.
*/
function error_displayable($error = NULL) {
$error_level = config('system.logging')->get('error_level');
$error_level = _drupal_get_error_level();
$updating = (defined('MAINTENANCE_MODE') && MAINTENANCE_MODE == 'update');
$all_errors_displayed = ($error_level == ERROR_REPORTING_DISPLAY_ALL) ||
($error_level == ERROR_REPORTING_DISPLAY_VERBOSE);
......@@ -254,7 +254,7 @@ function _drupal_log_error($error, $fatal = FALSE) {
$message = format_string('%type: !message in %function (line %line of %file).', $error);
// Check if verbose error reporting is on.
$error_level = config('system.logging')->get('error_level');
$error_level = _drupal_get_error_level();
if ($error_level == ERROR_REPORTING_DISPLAY_VERBOSE) {
// First trace is the error itself, already contained in the message.
......@@ -286,6 +286,29 @@ function _drupal_log_error($error, $fatal = FALSE) {
}
}
/**
* Returns the current error level.
*
* This function should only be used to get the current error level pre
* DRUPAL_BOOTSTRAP_KERNEL or before Drupal is installed. In all other
* situations the following code is preferred:
* @code
* Drupal::config('system.logging')->get('error_level');
* @endcode
*
* @return string
* The current error level.
*/
function _drupal_get_error_level() {
try {
return Drupal::config('system.logging')->get('error_level');
}
catch (Exception $e) {
// During very early install the cache_config table does not exist.
return ERROR_REPORTING_DISPLAY_ALL;
}
}
/**
* Gets the last caller from a backtrace.
*
......
<?php
use Drupal\Core\Config\FileStorage;
use Drupal\Core\DrupalKernel;
use Drupal\Core\CoreBundle;
use Drupal\Core\Database\Database;
......@@ -432,6 +433,16 @@ function install_begin_request(&$install_state) {
}
}
// Ensure that the active configuration directory is empty before installation
// starts.
if ($install_state['config_verified'] && empty($task)) {
$config = glob(config_get_config_directory(CONFIG_ACTIVE_DIRECTORY) . '/*.' . FileStorage::getFileExtension());
if (!empty($config)) {
$task = NULL;
throw new Exception(install_already_done_error());
}
}
// Modify the installation state as appropriate.
$install_state['completed_task'] = $task;
$install_state['database_tables_exist'] = !empty($task);
......@@ -1609,7 +1620,7 @@ function install_already_done_error() {
global $base_url;
drupal_set_title(st('Drupal already installed'));
return st('<ul><li>To start over, you must empty your existing database.</li><li>To install to a different database, edit the appropriate <em>settings.php</em> file in the <em>sites</em> folder.</li><li>To upgrade an existing installation, proceed to the <a href="@base-url/core/update.php">update script</a>.</li><li>View your <a href="@base-url">existing site</a>.</li></ul>', array('@base-url' => $base_url));
return st('<ul><li>To start over, you must empty your existing database, delete your active configuration, and copy <em>default.settings.php</em> over <em>settings.php</em>.</li><li>To install to a different database, edit the appropriate <em>settings.php</em> file in the <em>sites</em> folder.</li><li>To locate your active configuration, view the appropriate <em>settings.php</em> file in the <em>sites</em> folder.</em></li></li><li>To upgrade an existing installation, proceed to the <a href="@base-url/core/update.php">update script</a>.</li><li>View your <a href="@base-url">existing site</a>.</li></ul>', array('@base-url' => $base_url));
}
/**
......
......@@ -50,7 +50,17 @@ function _drupal_maintenance_theme() {
// Stark otherwise. Since there is no low-level access to configuration
// currently, we only consult settings.php and fall back to Bartik
// otherwise, as it looks generic enough and way more user-friendly.
$custom_theme = variable_get('maintenance_theme', config('system.theme')->get('default')) ?: 'bartik';
$custom_theme = variable_get('maintenance_theme');
if (!$custom_theme) {
$config = Drupal::config('system.theme');
// A broken install might not return an object.
if (is_object($config)) {
$custom_theme = $config->get('default');
}
}
if (!$custom_theme) {
$custom_theme = 'bartik';
}
}
// Ensure that system.module is loaded.
......
......@@ -397,7 +397,9 @@ function system_requirements($phase) {
}
}
else {
if (file_default_scheme() == 'public') {
// This function can be called before the config_cache table has been
// created.
if ($phase == 'install' || file_default_scheme() == 'public') {
$requirements['file system']['value'] = $t('Writable (<em>public</em> download method)');
}
else {
......
......@@ -719,6 +719,12 @@ function user_format_name($account) {
function user_template_preprocess_default_variables_alter(&$variables) {
global $user;
// If this function is called from the installer after Drupal has been
// installed then $user will not be set.
if (!is_object($user)) {
return;
}
$variables['user'] = clone $user;
// Remove password and session IDs, since themes should not need nor see them.
unset($variables['user']->pass, $variables['user']->sid, $variables['user']->ssid);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment