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;
$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
}
$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
*/
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 );
- }
}