From: Chad Horohoe Date: Fri, 10 Dec 2010 13:56:17 +0000 (+0000) Subject: Get rid of a bunch of $wgDBtypes in maintenance/ X-Git-Tag: 1.31.0-rc.0~33396 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/comptes/?a=commitdiff_plain;h=a548c1d87a4be629ae812726af6a3a3d0080a7ad;p=lhc%2Fweb%2Fwiklou.git Get rid of a bunch of $wgDBtypes in maintenance/ --- diff --git a/maintenance/rebuildall.php b/maintenance/rebuildall.php index 1dcd9a7fd6..3d2aebc4bf 100644 --- a/maintenance/rebuildall.php +++ b/maintenance/rebuildall.php @@ -30,9 +30,8 @@ class RebuildAll extends Maintenance { } public function execute() { - global $wgDBtype; // Rebuild the text index - if ( $wgDBtype != 'postgres' ) { + if ( wfGetDB( DB_SLAVE )->getType() != 'postgres' ) { $this->output( "** Rebuilding fulltext search index (if you abort this will break searching; run this script again to fix):\n" ); $rebuildText = $this->runChild( 'RebuildTextIndex', 'rebuildtextindex.php' ); $rebuildText->execute(); diff --git a/maintenance/rebuildtextindex.php b/maintenance/rebuildtextindex.php index 10550ea2e3..6c400bdbe5 100644 --- a/maintenance/rebuildtextindex.php +++ b/maintenance/rebuildtextindex.php @@ -40,10 +40,11 @@ class RebuildTextIndex extends Maintenance { } public function execute() { - global $wgTitle, $wgDBtype; + global $wgTitle; // Shouldn't be needed for Postgres - if ( $wgDBtype == 'postgres' ) { + $this->db = wfGetDB( DB_MASTER ); + if ( $this->db->getType() == 'postgres' ) { $this->error( "This script is not needed when using Postgres.\n", true ); } diff --git a/maintenance/sqlite.php b/maintenance/sqlite.php index 6a283281a9..e46b8e77e6 100644 --- a/maintenance/sqlite.php +++ b/maintenance/sqlite.php @@ -41,20 +41,18 @@ class SqliteMaintenance extends Maintenance { } public function execute() { - global $wgDBtype; - // Should work even if we use a non-SQLite database if ( $this->hasOption( 'check-syntax' ) ) { $this->checkSyntax(); } - if ( $wgDBtype != 'sqlite' ) { + $this->db = wfGetDB( DB_MASTER ); + + if ( $this->db->getType() != 'sqlite' ) { $this->error( "This maintenance script requires a SQLite database.\n" ); return; } - $this->db = wfGetDB( DB_MASTER ); - if ( $this->hasOption( 'vacuum' ) ) { $this->vacuum(); } diff --git a/maintenance/tests/parser/parserTest.inc b/maintenance/tests/parser/parserTest.inc index 1474760540..902133a196 100644 --- a/maintenance/tests/parser/parserTest.inc +++ b/maintenance/tests/parser/parserTest.inc @@ -723,13 +723,16 @@ class ParserTest { * the db will be visible to later tests in the run. */ public function setupDatabase() { - global $wgDBprefix, $wgDBtype; + global $wgDBprefix; if ( $this->databaseSetupDone ) { return; } - if ( $wgDBprefix === 'parsertest_' || ( $wgDBtype == 'oracle' && $wgDBprefix === 'pt_' ) ) { + $db = wfGetDB( DB_MASTER ); + $dbType = $db->getType(); + + if ( $wgDBprefix === 'parsertest_' || ( $dbType == 'oracle' && $wgDBprefix === 'pt_' ) ) { throw new MWException( 'setupDatabase should be called before setupGlobals' ); } @@ -745,9 +748,7 @@ class ParserTest { $this->useTemporaryTables = false; } - $temporary = $this->useTemporaryTables || $wgDBtype == 'postgres'; - - $db = wfGetDB( DB_MASTER ); + $temporary = $this->useTemporaryTables || $dbType == 'postgres'; $tables = $this->listTables(); foreach ( $tables as $tbl ) { @@ -756,12 +757,12 @@ class ParserTest { # fix back and forth so tableName() works right. $this->changePrefix( $this->oldTablePrefix ); $oldTableName = $db->tableName( $tbl ); - $this->changePrefix( $wgDBtype != 'oracle' ? 'parsertest_' : 'pt_' ); + $this->changePrefix( $dbType != 'oracle' ? 'parsertest_' : 'pt_' ); $newTableName = $db->tableName( $tbl ); - if ( $wgDBtype == 'mysql' ) { + if ( $dbType == 'mysql' ) { $db->query( "DROP TABLE IF EXISTS $newTableName" ); - } elseif ( in_array( $wgDBtype, array( 'postgres', 'oracle' ) ) ) { + } elseif ( in_array( $dbType, array( 'postgres', 'oracle' ) ) ) { /* DROPs wouldn't work due to Foreign Key Constraints (bug 14990, r58669) * Use "DROP TABLE IF EXISTS $newTableName CASCADE" for postgres? That * syntax would also work for mysql. @@ -774,12 +775,12 @@ class ParserTest { $db->duplicateTableStructure( $oldTableName, $newTableName, $temporary ); } - if ( $wgDBtype == 'oracle' ) + if ( $dbType == 'oracle' ) $db->query( 'BEGIN FILL_WIKI_INFO; END;' ); - $this->changePrefix( $wgDBtype != 'oracle' ? 'parsertest_' : 'pt_' ); + $this->changePrefix( $dbType != 'oracle' ? 'parsertest_' : 'pt_' ); - if ( $wgDBtype == 'oracle' ) { + if ( $dbType == 'oracle' ) { # Insert 0 user to prevent FK violations # Anonymous user @@ -882,8 +883,6 @@ class ParserTest { } public function teardownDatabase() { - global $wgDBtype; - if ( !$this->databaseSetupDone ) { $this->teardownGlobals(); return; @@ -903,11 +902,11 @@ class ParserTest { $db = wfGetDB( DB_MASTER ); foreach ( $tables as $table ) { - $sql = $wgDBtype == 'oracle' ? "DROP TABLE pt_$table DROP CONSTRAINTS" : "DROP TABLE `parsertest_$table`"; + $sql = $db->getType() == 'oracle' ? "DROP TABLE pt_$table DROP CONSTRAINTS" : "DROP TABLE `parsertest_$table`"; $db->query( $sql ); } - if ( $wgDBtype == 'oracle' ) + if ( $db->getType() == 'oracle' ) $db->query( 'BEGIN FILL_WIKI_INFO; END;' ); $this->teardownGlobals(); diff --git a/maintenance/tests/parserTests.php b/maintenance/tests/parserTests.php index 7793e6b8c7..bc3281624e 100644 --- a/maintenance/tests/parserTests.php +++ b/maintenance/tests/parserTests.php @@ -59,9 +59,8 @@ ENDS; # Cases of weird db corruption were encountered when running tests on earlyish # versions of SQLite -if ( $wgDBtype == 'sqlite' ) { - $db = wfGetDB( DB_MASTER ); - $version = $db->getServerVersion(); +if ( wfGetDB( DB_MASTER )->getType() == 'sqlite' ) { + $version = wfGetDB( DB_MASTER )->getServerVersion(); if ( version_compare( $version, '3.6' ) < 0 ) { die( "Parser tests require SQLite version 3.6 or later, you have $version\n" ); } diff --git a/maintenance/tests/testHelpers.inc b/maintenance/tests/testHelpers.inc index 94ca6abcbc..dc8b0fa8c2 100644 --- a/maintenance/tests/testHelpers.inc +++ b/maintenance/tests/testHelpers.inc @@ -302,7 +302,6 @@ class DbTestRecorder extends DbTestPreviewer { * and all that fun stuff */ function start() { - global $wgDBtype; $this->db->begin(); if ( ! $this->db->tableExists( 'testrun' ) @@ -324,7 +323,7 @@ class DbTestRecorder extends DbTestPreviewer { 'tr_uname' => php_uname() ), __METHOD__ ); - if ( $wgDBtype === 'postgres' ) { + if ( $this->db->getType() === 'postgres' ) { $this->curRun = $this->db->currentSequenceValue( 'testrun_id_seq' ); } else { $this->curRun = $this->db->insertId(); diff --git a/maintenance/upgrade1_5.php b/maintenance/upgrade1_5.php index 20429eb814..d26bfd6ca2 100644 --- a/maintenance/upgrade1_5.php +++ b/maintenance/upgrade1_5.php @@ -125,12 +125,10 @@ class FiveUpgrade extends Maintenance { * @access private */ function streamConnection() { - global $wgDBtype; - $timeout = 3600 * 24; $db = $this->newConnection(); $db->bufferResults( false ); - if ( $wgDBtype == 'mysql' ) { + if ( $db->getType() == 'mysql' ) { $db->query( "SET net_read_timeout=$timeout" ); $db->query( "SET net_write_timeout=$timeout" ); }