MediaWiki REL1_32
CloneDatabase Class Reference
Collaboration diagram for CloneDatabase:

Public Member Functions

 __construct (IMaintainableDatabase $db, array $tablesToClone, $newTablePrefix, $oldTablePrefix=null, $dropCurrentTables=true)
 
 cloneTableStructure ()
 Clone the table structure.
 
 destroy ( $dropTables=false)
 Change the prefix back to the original.
 
 useTemporaryTables ( $u=true)
 Set whether to use temporary tables or not.
 

Static Public Member Functions

static changePrefix ( $prefix)
 Change the table prefix on all open DB connections/.
 

Private Attributes

IMaintainableDatabase $db
 
bool $dropCurrentTables = true
 Should we DROP tables containing the new names?
 
string $newTablePrefix = ''
 Table prefix for cloning.
 
string $oldTablePrefix = ''
 Current table prefix.
 
array $tablesToClone = []
 List of tables to be cloned.
 
bool $useTemporaryTables = true
 Whether to use temporary tables or not.
 

Detailed Description

Definition at line 26 of file CloneDatabase.php.

Constructor & Destructor Documentation

◆ __construct()

CloneDatabase::__construct ( IMaintainableDatabase  $db,
array  $tablesToClone,
  $newTablePrefix,
  $oldTablePrefix = null,
  $dropCurrentTables = true 
)
Parameters
IMaintainableDatabase$dbA database subclass
array$tablesToCloneAn array of tables to clone, unprefixed
string$newTablePrefixPrefix to assign to the tables
string | null$oldTablePrefixPrefix on current tables, if not $wgDBprefix
bool$dropCurrentTables

Definition at line 52 of file CloneDatabase.php.

References $db, $dropCurrentTables, $newTablePrefix, $oldTablePrefix, $tablesToClone, and Wikimedia\Rdbms\IDatabase\tablePrefix().

Member Function Documentation

◆ changePrefix()

static CloneDatabase::changePrefix (   $prefix)
static

Change the table prefix on all open DB connections/.

Parameters
string$prefix
Returns
void

Definition at line 136 of file CloneDatabase.php.

References $wgDBprefix.

Referenced by ParserTestTopLevelSuite\setUp(), MediaWikiTestCase\setupAllTestDBs(), ParserTestRunner\setupDatabase(), ParserTestTopLevelSuite\tearDown(), and MediaWikiTestCase\teardownTestDB().

◆ cloneTableStructure()

CloneDatabase::cloneTableStructure ( )

Clone the table structure.

Definition at line 76 of file CloneDatabase.php.

References $wgSharedDB, $wgSharedTables, as, useTemporaryTables(), and wfDebug().

◆ destroy()

CloneDatabase::destroy (   $dropTables = false)

Change the prefix back to the original.

Parameters
bool$dropTablesOptionally drop the tables we created

Definition at line 120 of file CloneDatabase.php.

References as.

◆ useTemporaryTables()

CloneDatabase::useTemporaryTables (   $u = true)

Set whether to use temporary tables or not.

Parameters
bool$uUse temporary tables when cloning the structure

Definition at line 69 of file CloneDatabase.php.

References useTemporaryTables().

Referenced by cloneTableStructure(), and useTemporaryTables().

Member Data Documentation

◆ $db

IMaintainableDatabase CloneDatabase::$db
private

Definition at line 43 of file CloneDatabase.php.

Referenced by __construct().

◆ $dropCurrentTables

bool CloneDatabase::$dropCurrentTables = true
private

Should we DROP tables containing the new names?

Definition at line 37 of file CloneDatabase.php.

Referenced by __construct().

◆ $newTablePrefix

string CloneDatabase::$newTablePrefix = ''
private

Table prefix for cloning.

Definition at line 28 of file CloneDatabase.php.

Referenced by __construct().

◆ $oldTablePrefix

string CloneDatabase::$oldTablePrefix = ''
private

Current table prefix.

Definition at line 31 of file CloneDatabase.php.

Referenced by __construct().

◆ $tablesToClone

array CloneDatabase::$tablesToClone = []
private

List of tables to be cloned.

Definition at line 34 of file CloneDatabase.php.

Referenced by __construct().

◆ $useTemporaryTables

bool CloneDatabase::$useTemporaryTables = true
private

Whether to use temporary tables or not.

Definition at line 40 of file CloneDatabase.php.


The documentation for this class was generated from the following file: