Support for storing files under SHA-1 names
[lhc/web/wiklou.git] / includes / filerepo / ForeignDBRepo.php
index 6e9e6ad..dfdb375 100644 (file)
@@ -76,17 +76,8 @@ class ForeignDBRepo extends LocalRepo {
         */
        function getMasterDB() {
                if ( !isset( $this->dbConn ) ) {
-                       $this->dbConn = DatabaseBase::factory( $this->dbType,
-                               array(
-                                       'host' => $this->dbServer,
-                                       'user' => $this->dbUser,
-                                       'password' => $this->dbPassword,
-                                       'dbname' => $this->dbName,
-                                       'flags' => $this->dbFlags,
-                                       'tablePrefix' => $this->tablePrefix,
-                                       'foreign' => true,
-                               )
-                       );
+                       $func = $this->getDBFactory();
+                       $this->dbConn = $func( DB_MASTER );
                }
 
                return $this->dbConn;
@@ -99,6 +90,25 @@ class ForeignDBRepo extends LocalRepo {
                return $this->getMasterDB();
        }
 
+       /**
+        * @return Closure
+        */
+       protected function getDBFactory() {
+               return function( $index ) {
+                       return DatabaseBase::factory( $this->dbType,
+                               array(
+                                       'host' => $this->dbServer,
+                                       'user' => $this->dbUser,
+                                       'password' => $this->dbPassword,
+                                       'dbname' => $this->dbName,
+                                       'flags' => $this->dbFlags,
+                                       'tablePrefix' => $this->tablePrefix,
+                                       'foreign' => true,
+                               )
+                       );
+               };
+       }
+
        /**
         * @return bool
         */