From dd326e6913711fbb4d99b85953e43abe55c910b5 Mon Sep 17 00:00:00 2001
From: Thomas Skovgaard Gielfeldt <thomas@gielfeldt.dk>
Date: Mon, 4 Feb 2013 08:11:03 +0100
Subject: [PATCH] Issue #1893996 by gielfeldt: Respect the $databases structure when using multiple slave dbs.

---
 core/includes/bootstrap.inc |   30 +++++++++++++++++++-----------
 1 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc
index e959bf9..9402b10 100644
--- a/core/includes/bootstrap.inc
+++ b/core/includes/bootstrap.inc
@@ -2399,21 +2399,29 @@ function _drupal_initialize_db_test_prefix() {
     $test_info['in_child_site'] = TRUE;
 
     foreach ($GLOBALS['databases']['default'] as &$value) {
-      // Extract the current default database prefix.
-      if (!isset($value['prefix'])) {
-        $current_prefix = '';
-      }
-      elseif (is_array($value['prefix'])) {
-        $current_prefix = $value['prefix']['default'];
+      if (empty($value['driver'])) {
+        $values = &$value;
       }
       else {
-        $current_prefix = $value['prefix'];
+        $values = array(&$value);
       }
+      foreach ($values as &$value2) {
+        // Extract the current default database prefix.
+        if (!isset($value2['prefix'])) {
+          $current_prefix = '';
+        }
+        elseif (is_array($value2['prefix'])) {
+          $current_prefix = $value2['prefix']['default'];
+        }
+        else {
+          $current_prefix = $value2['prefix'];
+        }
 
-      // Remove the current database prefix and replace it by our own.
-      $value['prefix'] = array(
-        'default' => $current_prefix . $test_prefix,
-      );
+        // Remove the current database prefix and replace it by our own.
+        $value2['prefix'] = array(
+          'default' => $current_prefix . $test_prefix,
+        );
+      }
     }
   }
 }
-- 
1.7.0.4
