(bug 20372) Improve rollback-revisiondelete handling
[lhc/web/wiklou.git] / includes / ExternalStoreDB.php
index 9fa7d1b..c37e706 100644 (file)
@@ -26,21 +26,29 @@ $wgExternalBlobCache = array();
  */
 class ExternalStoreDB {
 
+       function __construct( $params = array() ) {
+               $this->mParams = $params;
+       }
+
        /** @todo Document.*/
        function &getLoadBalancer( $cluster ) {
-               return wfGetLBFactory()->getExternalLB( $cluster );
+               $wiki = isset($this->mParams['wiki']) ? $this->mParams['wiki'] : false;
+               
+               return wfGetLBFactory()->getExternalLB( $cluster, $wiki );
        }
 
        /** @todo Document.*/
        function &getSlave( $cluster ) {
+               $wiki = isset($this->mParams['wiki']) ? $this->mParams['wiki'] : false;
                $lb =& $this->getLoadBalancer( $cluster );
-               return $lb->getConnection( DB_SLAVE );
+               return $lb->getConnection( DB_SLAVE, array(), $wiki );
        }
 
        /** @todo Document.*/
        function &getMaster( $cluster ) {
+               $wiki = isset($this->mParams['wiki']) ? $this->mParams['wiki'] : false;
                $lb =& $this->getLoadBalancer( $cluster );
-               return $lb->getConnection( DB_MASTER );
+               return $lb->getConnection( DB_MASTER, array(), $wiki );
        }
 
        /** @todo Document.*/
@@ -128,6 +136,9 @@ class ExternalStoreDB {
                        array( 'blob_id' => $id, 'blob_text' => $data ), 
                        __METHOD__ );
                $id = $dbw->insertId();
+               if ( !$id ) {
+                       throw new MWException( __METHOD__.': no insert ID' );
+               }
                if ( $dbw->getFlag( DBO_TRX ) ) {
                        $dbw->immediateCommit();
                }