Index: includes/install.core.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/install.core.inc,v
retrieving revision 1.25
diff -u -r1.25 install.core.inc
--- includes/install.core.inc	2 Jul 2010 15:32:10 -0000	1.25
+++ includes/install.core.inc	13 Jul 2010 02:39:52 -0000
@@ -1014,7 +1014,15 @@
     'value'    => drupal_hash_base64(drupal_random_bytes(55)),
     'required' => TRUE,
   );
-  drupal_rewrite_settings($settings);
+  $buffer = drupal_rewrite_settings($settings);
+  drupal_static_reset('conf_path');
+  $settings_file = conf_path(FALSE) . '/' . $prefix . 'settings.php';
+
+  $fp = fopen(DRUPAL_ROOT . '/' . $settings_file, 'w');
+  if ($fp && fwrite($fp, $buffer) === FALSE) {
+    throw new Exception(st('Failed to modify %settings. Verify the file permissions.', array('%settings' => $settings_file)));
+  }
+
   // 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
   // last step is important since we want to trigger an error if the new
Index: includes/install.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/install.inc,v
retrieving revision 1.136
diff -u -r1.136 install.inc
--- includes/install.inc	21 Jun 2010 02:27:47 -0000	1.136
+++ includes/install.inc	13 Jul 2010 02:39:53 -0000
@@ -421,15 +421,16 @@
 }
 
 /**
- * Replace values in settings.php with values in the submitted array.
+ * Replaces values in the default settings file and returns the contents.
  *
  * @param $settings
  *   An array of settings that need to be updated.
+ *
+ * @return
+ *   A string suitible for writing to settings.php
  */
 function drupal_rewrite_settings($settings = array(), $prefix = '') {
   $default_settings = 'sites/default/default.settings.php';
-  drupal_static_reset('conf_path');
-  $settings_file = conf_path(FALSE) . '/' . $prefix . 'settings.php';
 
   // Build list of setting names and insert the values into the global namespace.
   $keys = array();
@@ -487,11 +488,8 @@
         $buffer .= "\$$setting = " . var_export($data['value'], TRUE) . ";\n";
       }
     }
-
-    $fp = fopen(DRUPAL_ROOT . '/' . $settings_file, 'w');
-    if ($fp && fwrite($fp, $buffer) === FALSE) {
-      throw new Exception(st('Failed to modify %settings. Verify the file permissions.', array('%settings' => $settings_file)));
-    }
+    
+    return $buffer;
   }
   else {
     throw new Exception(st('Failed to open %settings. Verify the file permissions.', array('%settings' => $default_settings)));
