From 2c229492a1736f030cfdd4392042ede2a2a29f93 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/update.inc | 33 ++++++++++++++++++++++++++++++++- 1 files changed, 32 insertions(+), 1 deletions(-) diff --git a/core/includes/update.inc b/core/includes/update.inc index ab373cd..89f7e51 100644 --- a/core/includes/update.inc +++ b/core/includes/update.inc @@ -83,11 +83,25 @@ function update_check_incompatibility($name, $type = 'module') { * irreversible changes to the database are made here. */ function update_prepare_d8_bootstrap() { + global $config_directory_name; + // Allow the database system to work even if the registry has not been // created yet. 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 +113,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 +129,21 @@ function update_prepare_d8_bootstrap() { // Update the environment for the language bootstrap if needed. update_prepare_d8_language(); + if ($writable) { + // 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); + + $config_directory = config_get_config_directory(); + $result = file_prepare_directory($config_directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS); + } + // 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