Merge "Make JobQueueGroup::push() update the queuesHaveJobs() cache"
[lhc/web/wiklou.git] / includes / db / CloneDatabase.php
index 9eb3e2f..577c98d 100644 (file)
@@ -32,7 +32,7 @@ class CloneDatabase {
        private $oldTablePrefix = '';
 
        /** @var array List of tables to be cloned */
-       private $tablesToClone = array();
+       private $tablesToClone = [];
 
        /** @var bool Should we DROP tables containing the new names? */
        private $dropCurrentTables = true;
@@ -89,7 +89,7 @@ class CloneDatabase {
                        $newTableName = $this->db->tableName( $tbl, 'raw' );
 
                        if ( $this->dropCurrentTables
-                               && !in_array( $this->db->getType(), array( 'postgres', 'oracle' ) )
+                               && !in_array( $this->db->getType(), [ 'postgres', 'oracle' ] )
                        ) {
                                if ( $oldTableName === $newTableName ) {
                                        // Last ditch check to avoid data loss
@@ -98,7 +98,7 @@ class CloneDatabase {
                                }
                                $this->db->dropTable( $tbl, __METHOD__ );
                                wfDebug( __METHOD__ . " dropping {$newTableName}\n" );
-                               //Dropping the oldTable because the prefix was changed
+                               // Dropping the oldTable because the prefix was changed
                        }
 
                        # Create new table
@@ -129,25 +129,11 @@ class CloneDatabase {
         */
        public static function changePrefix( $prefix ) {
                global $wgDBprefix;
-               wfGetLBFactory()->forEachLB( array( 'CloneDatabase', 'changeLBPrefix' ), array( $prefix ) );
+               wfGetLBFactory()->forEachLB( function( $lb ) use ( $prefix ) {
+                       $lb->forEachOpenConnection( function ( $db ) use ( $prefix ) {
+                               $db->tablePrefix( $prefix );
+                       } );
+               } );
                $wgDBprefix = $prefix;
        }
-
-       /**
-        * @param LoadBalancer $lb
-        * @param string $prefix
-        * @return void
-        */
-       public static function changeLBPrefix( $lb, $prefix ) {
-               $lb->forEachOpenConnection( array( 'CloneDatabase', 'changeDBPrefix' ), array( $prefix ) );
-       }
-
-       /**
-        * @param DatabaseBase $db
-        * @param string $prefix
-        * @return void
-        */
-       public static function changeDBPrefix( $db, $prefix ) {
-               $db->tablePrefix( $prefix );
-       }
 }