diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index c145cc7..94d2754 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -899,23 +899,6 @@ function install_verify_pdo() { } /** - * Ensure that the config directory exists and is writable, or can be made so. - */ -function install_ensure_config_directory() { - // The config directory must be defined in settings.php. - global $config_directory_name; - if (empty($config_directory_name)) { - return FALSE; - } - // The logic here is similar to that used by system_requirements() for other - // directories that the installer creates. - else { - $config_directory = config_get_config_directory(); - return file_prepare_directory($config_directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS); - } -} - -/** * Installation task; define a form to configure and rewrite settings.php. * * @param $form_state @@ -1050,7 +1033,7 @@ function install_database_errors($database, $settings_file) { * Form API submit for install_settings form. */ function install_settings_form_submit($form, &$form_state) { - global $install_state, $config_directory_name; + global $install_state; // Update global settings array and save. $settings['databases'] = array( @@ -1062,26 +1045,10 @@ function install_settings_form_submit($form, &$form_state) { 'required' => TRUE, ); - // Add the config directory to settings.php. If someone already defined one - // in the existing settings.php, use that; otherwise, use a randomized - // directory name. - $settings['config_directory_name'] = array( - 'value' => $config_directory_name ? $config_directory_name : 'config_' . drupal_hash_base64(drupal_random_bytes(55)), - 'required' => TRUE, - ); - drupal_rewrite_settings($settings); - // Ensure that the new config directory can be created and made writable. - if (!install_ensure_config_directory()) { - // This should never fail, since if the config directory was specified in - // settings.php it will have already been created and verified earlier, and - // if it wasn't specified in settings.php, it is created here inside the - // public files directory, which has already been verified to be writable - // itself. But if it somehow fails anyway, the installation cannot proceed. - // Bail out using a similar error message as in system_requirements(). - throw new Exception(st('The directory %directory could not be created or could not be made writable. To proceed with the installation, either create the directory and modify its permissions manually or ensure that the installer has the permissions to create it automatically. For more information, see the online handbook.', array('%directory' => config_get_config_directory(), '@handbook_url' => 'http://drupal.org/server-permissions'))); - } + // Add the config directory to settings.php. + drupal_install_config_directory(); // Indicate that the settings file has been verified, and check the database // for the last completed task, now that we have a valid connection. This diff --git a/core/includes/install.inc b/core/includes/install.inc index cd67257..e5dc383 100644 --- a/core/includes/install.inc +++ b/core/includes/install.inc @@ -249,6 +249,58 @@ function drupal_rewrite_settings($settings = array()) { } /** + * Creates the config directory and ensures it is operational. + * + * @see install_settings_form_submit() + * @see update_prepare_d8_bootstrap() + */ +function drupal_install_config_directory() { + global $config_directory_name; + + // Add a randomized config directory name to settings.php, unless it was + // manually defined in the existing already. + if (!$config_directory_name) { + $settings['config_directory_name'] = array( + 'value' => 'config_' . drupal_hash_base64(drupal_random_bytes(55)), + 'required' => TRUE, + ); + // Rewrite settings.php, which also sets the value as global variable. + drupal_rewrite_settings($settings); + } + + // Ensure that the config directory exists or can be created, and is writable. + if (!install_ensure_config_directory()) { + // This should never fail, since if the config directory was specified in + // settings.php it will have already been created and verified earlier, and + // if it wasn't specified in settings.php, it is created here inside the + // public files directory, which has already been verified to be writable + // itself. But if it somehow fails anyway, the installation cannot proceed. + // Bail out using a similar error message as in system_requirements(). + throw new Exception(st('The directory %directory could not be created or could not be made writable. To proceed with the installation, either create the directory and modify its permissions manually or ensure that the installer has the permissions to create it automatically. For more information, see the online handbook.', array( + '%directory' => config_get_config_directory(), + '@handbook_url' => 'http://drupal.org/server-permissions', + ))); + } +} + +/** + * Ensures that the config directory exists and is writable, or can be made so. + */ +function install_ensure_config_directory() { + // The config directory must be defined in settings.php. + global $config_directory_name; + if (empty($config_directory_name)) { + return FALSE; + } + // The logic here is similar to that used by system_requirements() for other + // directories that the installer creates. + else { + $config_directory = config_get_config_directory(); + return file_prepare_directory($config_directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS); + } +} + +/** * Verify an install profile for installation. * * @param $install_state diff --git a/core/includes/update.inc b/core/includes/update.inc index ab373cd..8899cc3 100644 --- a/core/includes/update.inc +++ b/core/includes/update.inc @@ -88,6 +88,18 @@ function update_prepare_d8_bootstrap() { include_once DRUPAL_ROOT . '/core/includes/install.inc'; drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE); + $settings_file = conf_path() . '/settings.php'; + $writable = drupal_verify_install_file($settings_file, FILE_EXIST | FILE_READABLE | FILE_WRITABLE); + $requirements = array( + 'settings file' => array( + 'title' => 'Settings file', + 'value' => $writable ? 'The settings file is writable.' : 'The settings file is not writable.', + 'severity' => $writable ? NULL : REQUIREMENT_ERROR, + 'description' => $writable ? '' : 'Drupal requires write permissions to ' . $settings_file . ' during the update process. If you are unsure how to grant file permissions, consult the online handbook.', + ), + ); + update_extra_requirements($requirements); + // If the site has not updated to Drupal 8 yet, check to make sure that it is // running an up-to-date version of Drupal 7 before proceeding. Note this has // to happen AFTER the database bootstraps because of @@ -99,10 +111,12 @@ function update_prepare_d8_bootstrap() { 'drupal 7 version' => array( 'title' => 'Drupal 7 version', 'value' => $has_required_schema ? 'You are running a current version of Drupal 7.' : 'You are not running a current version of Drupal 7', - 'severity' => $has_required_schema ? REQUIREMENT_OK : REQUIREMENT_ERROR, + 'severity' => $has_required_schema ? NULL : REQUIREMENT_ERROR, 'description' => $has_required_schema ? '' : 'Please update your Drupal 7 installation to the most recent version before attempting to upgrade to Drupal 8', ), ); + update_extra_requirements($requirements); + if ($has_required_schema) { // Bootstrap variables so we can update theme while preparing the update // process. @@ -113,6 +127,12 @@ function update_prepare_d8_bootstrap() { // Update the environment for the language bootstrap if needed. update_prepare_d8_language(); + // Ensure the configuration directory exists and is writable or create it. + // If no $config_directory_name has been specified in settings.php and + // created manually already, and the directory cannot be created by the + // web server, an exception will be thrown, halting the update. + drupal_install_config_directory(); + // Change language column to langcode in url_alias. if (db_table_exists('url_alias') && db_field_exists('url_alias', 'language')) { db_drop_index('url_alias', 'alias_language_pid');