Merge "Use @lang tags for Lua scripts"
[lhc/web/wiklou.git] / includes / filerepo / ForeignDBRepo.php
index 92f017f..001800f 100644 (file)
@@ -53,8 +53,8 @@ class ForeignDBRepo extends LocalRepo {
 
        # Other stuff
        protected $dbConn;
-       protected $fileFactory = array( 'ForeignDBFile', 'newFromTitle' );
-       protected $fileFromRowFactory = array( 'ForeignDBFile', 'newFromRow' );
+       protected $fileFactory = [ 'ForeignDBFile', 'newFromTitle' ];
+       protected $fileFromRowFactory = [ 'ForeignDBFile', 'newFromRow' ];
 
        /**
         * @param array|null $info
@@ -72,33 +72,44 @@ class ForeignDBRepo extends LocalRepo {
        }
 
        /**
-        * @return DatabaseBase
+        * @return IDatabase
         */
        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;
        }
 
        /**
-        * @return DatabaseBase
+        * @return IDatabase
         */
        function getSlaveDB() {
                return $this->getMasterDB();
        }
 
+       /**
+        * @return Closure
+        */
+       protected function getDBFactory() {
+               $type = $this->dbType;
+               $params = [
+                       'host' => $this->dbServer,
+                       'user' => $this->dbUser,
+                       'password' => $this->dbPassword,
+                       'dbname' => $this->dbName,
+                       'flags' => $this->dbFlags,
+                       'tablePrefix' => $this->tablePrefix,
+                       'foreign' => true,
+               ];
+
+               return function ( $index ) use ( $type, $params ) {
+                       return DatabaseBase::factory( $type, $params );
+               };
+       }
+
        /**
         * @return bool
         */
@@ -126,4 +137,14 @@ class ForeignDBRepo extends LocalRepo {
        protected function assertWritableRepo() {
                throw new MWException( get_class( $this ) . ': write operations are not supported.' );
        }
+
+       /**
+        * Return information about the repository.
+        *
+        * @return array
+        * @since 1.22
+        */
+       function getInfo() {
+               return FileRepo::getInfo();
+       }
 }