More places to fix if no split DB is configured
authorMichael M Slusarz <slusarz@curecanti.org>
Thu, 13 May 2010 21:37:58 +0000 (15:37 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Thu, 13 May 2010 21:37:58 +0000 (15:37 -0600)
framework/Alarm/lib/Horde/Alarm/Sql.php
framework/Cache/lib/Horde/Cache/Sql.php
framework/Lock/lib/Horde/Lock/Sql.php
framework/Perms/lib/Horde/Perms/Sql.php
framework/SessionHandler/lib/Horde/SessionHandler/Sql.php

index 2a9f503..fc98ea3 100644 (file)
@@ -55,11 +55,9 @@ class Horde_Alarm_Sql extends Horde_Alarm
         }
         $this->_db = $params['db'];
 
-        if (isset($params['write_db'])) {
-            $this->_write_db = $params['write_db'];
-        } else {
-            $this->_write_db = $this->_db;
-        }
+        $this->_write_db = isset($params['write_db'])
+            ? $params['write_db']
+            : $this->_db;
 
         unset($params['db'], $params['write_db']);
 
index 5e0c769..f1a31a0 100644 (file)
@@ -74,9 +74,9 @@ class Horde_Cache_Sql extends Horde_Cache_Base
         }
         $this->_db = $params['db'];
 
-        if (isset($params['write_db'])) {
-            $this->_write_db = $params['write_db'];
-        }
+        $this->_write_db = isset($params['write_db'])
+            ? $params['write_db']
+            : $this->_db;
 
         if (isset($params['use_memorycache'])) {
             $this->_mc = $params['use_memorycache'];
index c7b2add..e240559 100644 (file)
@@ -65,9 +65,9 @@ class Horde_Lock_Sql extends Horde_Lock_Driver
         }
         $this->_db = $params['db'];
 
-        if (isset($params['write_db'])) {
-            $this->_write_db = $params['write_db'];
-        }
+        $this->_write_db = isset($params['write_db'])
+            ? $params['write_db']
+            : $this->_db;
 
         unset($params['db'], $params['write_db']);
 
index 66f0b85..dd2937b 100644 (file)
@@ -71,9 +71,9 @@ class Horde_Perms_Sql extends Horde_Perms
         }
         $this->_db = $params['db'];
 
-        if (isset($params['write_db'])) {
-            $this->_write_db = $params['write_db'];
-        }
+        $this->_write_db = isset($params['write_db'])
+            ? $params['write_db']
+            : $this->_db;
 
         unset($params['db'], $params['write_db']);
 
index 3eac8df..0be3fa7 100644 (file)
@@ -53,6 +53,10 @@ class Horde_SessionHandler_Sql extends Horde_SessionHandler
         }
         $this->_db = $params['db'];
 
+        $this->_write_db = isset($params['write_db'])
+            ? $params['write_db']
+            : $this->_db;
+
         if (isset($params['write_db'])) {
             $this->_write_db = $params['write_db'];
         }
@@ -79,7 +83,7 @@ class Horde_SessionHandler_Sql extends Horde_SessionHandler
         $this->_db->autoCommit(true);
         @$this->_db->disconnect();
 
-        if ($this->_write_db) {
+        if ($this->_db != $this->_write_db) {
             $this->_write_db->commit();
             $this->_write_db->autoCommit(true);
             @$this->_write_db->disconnect();