diff --git a/core/includes/errors.inc b/core/includes/errors.inc index 5fc4b7d3d2a07da7dc5de0decfac9adce0155db8..f29def777fe77cb7e1a85b6595ee71b15462d952 100644 --- a/core/includes/errors.inc +++ b/core/includes/errors.inc @@ -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. * diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index df688ab19a1ae548d70b38a0d237df3ae4c4c1e8..85dc45ce90d5dcafa4f7568fa7265c5de674cec0 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -1,5 +1,6 @@ <?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)); } /** diff --git a/core/includes/theme.maintenance.inc b/core/includes/theme.maintenance.inc index 37775e6da6b554422278ba49aa5a5c04b74472f2..cda4109241c5adf443a2f86b51f5c8af23560fe0 100644 --- a/core/includes/theme.maintenance.inc +++ b/core/includes/theme.maintenance.inc @@ -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. diff --git a/core/modules/system/system.install b/core/modules/system/system.install index a93a124c16e8fdf1c45da0c48cd60e33d5e0ff5a..445b27c4aac1bedc4c1dbea48b0cc3f8d86985bd 100644 --- a/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -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 { diff --git a/core/modules/user/user.module b/core/modules/user/user.module index bdf5862739c85b3c68bcfa6649fb305cb9df1507..46f880774473a8ff1f144168fb2ac674bc9f7f5b 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -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);