(bug 20372) Improve rollback-revisiondelete handling
[lhc/web/wiklou.git] / includes / ExternalStoreDB.php
index cb3c331..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, array() );
+               return $lb->getConnection( DB_MASTER, array(), $wiki );
        }
 
        /** @todo Document.*/
@@ -123,14 +131,14 @@ class ExternalStoreDB {
         */
        function store( $cluster, $data ) {
                $dbw = $this->getMaster( $cluster );
-               #if( !$dbw ) {
-               #       return false;
-               #}
                $id = $dbw->nextSequenceValue( 'blob_blob_id_seq' );
                $dbw->insert( $this->getTable( $dbw ), 
                        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();
                }