From e26c8c05befda261e83c14e82ac4d44bb469d612 Mon Sep 17 00:00:00 2001
From: Bram Goffings <bramgoffings@gmail.com>
Date: Sat, 30 Jun 2012 15:25:03 +0200
Subject: [PATCH] fixed config upgrade path

---
 core/includes/update.inc |   29 ++++++++++++++++++++++++++++-
 1 files changed, 28 insertions(+), 1 deletions(-)

diff --git a/core/includes/update.inc b/core/includes/update.inc
index ab373cd..17d0b20 100644
--- a/core/includes/update.inc
+++ b/core/includes/update.inc
@@ -88,6 +88,31 @@ function update_prepare_d8_bootstrap() {
   include_once DRUPAL_ROOT . '/core/includes/install.inc';
   drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE);
 
+  global $databases, $db_url, $db_prefix, $update_rewrite_settings, $config_directory_name;
+  $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 <em>' . $settings_file . '</em> during the update process. If you are unsure how to grant file permissions, consult the <a href="http://drupal.org/server-permissions">online handbook</a>.',
+    ),
+  );
+  update_extra_requirements($requirements);
+
+  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);
+  }
+
   // 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 +124,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.
-- 
1.7.4.msysgit.0

