Update more docs and type hints to use IDatabase
[lhc/web/wiklou.git] / includes / filerepo / ForeignDBRepo.php
index 92f017f..f3a560b 100644 (file)
@@ -72,11 +72,30 @@ class ForeignDBRepo extends LocalRepo {
        }
 
        /**
-        * @return DatabaseBase
+        * @return IDatabase
         */
        function getMasterDB() {
                if ( !isset( $this->dbConn ) ) {
-                       $this->dbConn = DatabaseBase::factory( $this->dbType,
+                       $func = $this->getDBFactory();
+                       $this->dbConn = $func( DB_MASTER );
+               }
+
+               return $this->dbConn;
+       }
+
+       /**
+        * @return IDatabase
+        */
+       function getSlaveDB() {
+               return $this->getMasterDB();
+       }
+
+       /**
+        * @return Closure
+        */
+       protected function getDBFactory() {
+               return function( $index ) {
+                       return DatabaseBase::factory( $this->dbType,
                                array(
                                        'host' => $this->dbServer,
                                        'user' => $this->dbUser,
@@ -87,16 +106,7 @@ class ForeignDBRepo extends LocalRepo {
                                        'foreign' => true,
                                )
                        );
-               }
-
-               return $this->dbConn;
-       }
-
-       /**
-        * @return DatabaseBase
-        */
-       function getSlaveDB() {
-               return $this->getMasterDB();
+               };
        }
 
        /**
@@ -126,4 +136,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();
+       }
 }