From eb72c5da46fa883bbabed6778c6e0bb7092a196b Mon Sep 17 00:00:00 2001 From: Bram Goffings Date: Sat, 30 Jun 2012 16:08:35 +0200 Subject: [PATCH] fixed config upgrade path --- core/includes/install.core.inc | 40 +--------------------------------- core/includes/install.inc | 45 ++++++++++++++++++++++++++++++++++++++++ core/includes/update.inc | 20 ++++++++++++++++- 3 files changed, 66 insertions(+), 39 deletions(-) diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index eb9dff9..96f5326 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,7 @@ 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'))); - } + drupal_config_folder_create($settings); // 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..c9e8f64 100644 --- a/core/includes/install.inc +++ b/core/includes/install.inc @@ -910,3 +910,48 @@ function db_installer_object($driver) { $task_class = "Drupal\\Core\\Database\\Driver\\{$driver}\\Install\\Tasks"; return new $task_class(); } + +/** + * Creates a config folder. + */ +function drupal_config_folder_create($settings = array()) { + global $config_directory_name; + + // 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'))); + } +} + +/** + * 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); + } +} diff --git a/core/includes/update.inc b/core/includes/update.inc index ab373cd..e37ae53 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,10 @@ function update_prepare_d8_bootstrap() { // Update the environment for the language bootstrap if needed. update_prepare_d8_language(); + if ($writable) { + drupal_config_folder_create(); + } + // 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'); -- 1.7.4.msysgit.0