Index: trunk/phase3/maintenance/tests/parserTests.php |
— | — | @@ -59,9 +59,8 @@ |
60 | 60 | |
61 | 61 | # Cases of weird db corruption were encountered when running tests on earlyish |
62 | 62 | # versions of SQLite |
63 | | -if ( $wgDBtype == 'sqlite' ) { |
64 | | - $db = wfGetDB( DB_MASTER ); |
65 | | - $version = $db->getServerVersion(); |
| 63 | +if ( wfGetDB( DB_MASTER )->getType() == 'sqlite' ) { |
| 64 | + $version = wfGetDB( DB_MASTER )->getServerVersion(); |
66 | 65 | if ( version_compare( $version, '3.6' ) < 0 ) { |
67 | 66 | die( "Parser tests require SQLite version 3.6 or later, you have $version\n" ); |
68 | 67 | } |
Index: trunk/phase3/maintenance/tests/testHelpers.inc |
— | — | @@ -302,7 +302,6 @@ |
303 | 303 | * and all that fun stuff |
304 | 304 | */ |
305 | 305 | function start() { |
306 | | - global $wgDBtype; |
307 | 306 | $this->db->begin(); |
308 | 307 | |
309 | 308 | if ( ! $this->db->tableExists( 'testrun' ) |
— | — | @@ -324,7 +323,7 @@ |
325 | 324 | 'tr_uname' => php_uname() |
326 | 325 | ), |
327 | 326 | __METHOD__ ); |
328 | | - if ( $wgDBtype === 'postgres' ) { |
| 327 | + if ( $this->db->getType() === 'postgres' ) { |
329 | 328 | $this->curRun = $this->db->currentSequenceValue( 'testrun_id_seq' ); |
330 | 329 | } else { |
331 | 330 | $this->curRun = $this->db->insertId(); |
Index: trunk/phase3/maintenance/tests/parser/parserTest.inc |
— | — | @@ -723,13 +723,16 @@ |
724 | 724 | * the db will be visible to later tests in the run. |
725 | 725 | */ |
726 | 726 | public function setupDatabase() { |
727 | | - global $wgDBprefix, $wgDBtype; |
| 727 | + global $wgDBprefix; |
728 | 728 | |
729 | 729 | if ( $this->databaseSetupDone ) { |
730 | 730 | return; |
731 | 731 | } |
732 | 732 | |
733 | | - if ( $wgDBprefix === 'parsertest_' || ( $wgDBtype == 'oracle' && $wgDBprefix === 'pt_' ) ) { |
| 733 | + $db = wfGetDB( DB_MASTER ); |
| 734 | + $dbType = $db->getType(); |
| 735 | + |
| 736 | + if ( $wgDBprefix === 'parsertest_' || ( $dbType == 'oracle' && $wgDBprefix === 'pt_' ) ) { |
734 | 737 | throw new MWException( 'setupDatabase should be called before setupGlobals' ); |
735 | 738 | } |
736 | 739 | |
— | — | @@ -745,9 +748,7 @@ |
746 | 749 | $this->useTemporaryTables = false; |
747 | 750 | } |
748 | 751 | |
749 | | - $temporary = $this->useTemporaryTables || $wgDBtype == 'postgres'; |
750 | | - |
751 | | - $db = wfGetDB( DB_MASTER ); |
| 752 | + $temporary = $this->useTemporaryTables || $dbType == 'postgres'; |
752 | 753 | $tables = $this->listTables(); |
753 | 754 | |
754 | 755 | foreach ( $tables as $tbl ) { |
— | — | @@ -756,12 +757,12 @@ |
757 | 758 | # fix back and forth so tableName() works right. |
758 | 759 | $this->changePrefix( $this->oldTablePrefix ); |
759 | 760 | $oldTableName = $db->tableName( $tbl ); |
760 | | - $this->changePrefix( $wgDBtype != 'oracle' ? 'parsertest_' : 'pt_' ); |
| 761 | + $this->changePrefix( $dbType != 'oracle' ? 'parsertest_' : 'pt_' ); |
761 | 762 | $newTableName = $db->tableName( $tbl ); |
762 | 763 | |
763 | | - if ( $wgDBtype == 'mysql' ) { |
| 764 | + if ( $dbType == 'mysql' ) { |
764 | 765 | $db->query( "DROP TABLE IF EXISTS $newTableName" ); |
765 | | - } elseif ( in_array( $wgDBtype, array( 'postgres', 'oracle' ) ) ) { |
| 766 | + } elseif ( in_array( $dbType, array( 'postgres', 'oracle' ) ) ) { |
766 | 767 | /* DROPs wouldn't work due to Foreign Key Constraints (bug 14990, r58669) |
767 | 768 | * Use "DROP TABLE IF EXISTS $newTableName CASCADE" for postgres? That |
768 | 769 | * syntax would also work for mysql. |
— | — | @@ -774,12 +775,12 @@ |
775 | 776 | $db->duplicateTableStructure( $oldTableName, $newTableName, $temporary ); |
776 | 777 | } |
777 | 778 | |
778 | | - if ( $wgDBtype == 'oracle' ) |
| 779 | + if ( $dbType == 'oracle' ) |
779 | 780 | $db->query( 'BEGIN FILL_WIKI_INFO; END;' ); |
780 | 781 | |
781 | | - $this->changePrefix( $wgDBtype != 'oracle' ? 'parsertest_' : 'pt_' ); |
| 782 | + $this->changePrefix( $dbType != 'oracle' ? 'parsertest_' : 'pt_' ); |
782 | 783 | |
783 | | - if ( $wgDBtype == 'oracle' ) { |
| 784 | + if ( $dbType == 'oracle' ) { |
784 | 785 | # Insert 0 user to prevent FK violations |
785 | 786 | |
786 | 787 | # Anonymous user |
— | — | @@ -882,8 +883,6 @@ |
883 | 884 | } |
884 | 885 | |
885 | 886 | public function teardownDatabase() { |
886 | | - global $wgDBtype; |
887 | | - |
888 | 887 | if ( !$this->databaseSetupDone ) { |
889 | 888 | $this->teardownGlobals(); |
890 | 889 | return; |
— | — | @@ -903,11 +902,11 @@ |
904 | 903 | $db = wfGetDB( DB_MASTER ); |
905 | 904 | |
906 | 905 | foreach ( $tables as $table ) { |
907 | | - $sql = $wgDBtype == 'oracle' ? "DROP TABLE pt_$table DROP CONSTRAINTS" : "DROP TABLE `parsertest_$table`"; |
| 906 | + $sql = $db->getType() == 'oracle' ? "DROP TABLE pt_$table DROP CONSTRAINTS" : "DROP TABLE `parsertest_$table`"; |
908 | 907 | $db->query( $sql ); |
909 | 908 | } |
910 | 909 | |
911 | | - if ( $wgDBtype == 'oracle' ) |
| 910 | + if ( $db->getType() == 'oracle' ) |
912 | 911 | $db->query( 'BEGIN FILL_WIKI_INFO; END;' ); |
913 | 912 | |
914 | 913 | $this->teardownGlobals(); |
Index: trunk/phase3/maintenance/rebuildall.php |
— | — | @@ -30,9 +30,8 @@ |
31 | 31 | } |
32 | 32 | |
33 | 33 | public function execute() { |
34 | | - global $wgDBtype; |
35 | 34 | // Rebuild the text index |
36 | | - if ( $wgDBtype != 'postgres' ) { |
| 35 | + if ( wfGetDB( DB_SLAVE )->getType() != 'postgres' ) { |
37 | 36 | $this->output( "** Rebuilding fulltext search index (if you abort this will break searching; run this script again to fix):\n" ); |
38 | 37 | $rebuildText = $this->runChild( 'RebuildTextIndex', 'rebuildtextindex.php' ); |
39 | 38 | $rebuildText->execute(); |
Index: trunk/phase3/maintenance/upgrade1_5.php |
— | — | @@ -125,12 +125,10 @@ |
126 | 126 | * @access private |
127 | 127 | */ |
128 | 128 | function streamConnection() { |
129 | | - global $wgDBtype; |
130 | | - |
131 | 129 | $timeout = 3600 * 24; |
132 | 130 | $db = $this->newConnection(); |
133 | 131 | $db->bufferResults( false ); |
134 | | - if ( $wgDBtype == 'mysql' ) { |
| 132 | + if ( $db->getType() == 'mysql' ) { |
135 | 133 | $db->query( "SET net_read_timeout=$timeout" ); |
136 | 134 | $db->query( "SET net_write_timeout=$timeout" ); |
137 | 135 | } |
Index: trunk/phase3/maintenance/rebuildtextindex.php |
— | — | @@ -40,10 +40,11 @@ |
41 | 41 | } |
42 | 42 | |
43 | 43 | public function execute() { |
44 | | - global $wgTitle, $wgDBtype; |
| 44 | + global $wgTitle; |
45 | 45 | |
46 | 46 | // Shouldn't be needed for Postgres |
47 | | - if ( $wgDBtype == 'postgres' ) { |
| 47 | + $this->db = wfGetDB( DB_MASTER ); |
| 48 | + if ( $this->db->getType() == 'postgres' ) { |
48 | 49 | $this->error( "This script is not needed when using Postgres.\n", true ); |
49 | 50 | } |
50 | 51 | |
Index: trunk/phase3/maintenance/sqlite.php |
— | — | @@ -41,20 +41,18 @@ |
42 | 42 | } |
43 | 43 | |
44 | 44 | public function execute() { |
45 | | - global $wgDBtype; |
46 | | - |
47 | 45 | // Should work even if we use a non-SQLite database |
48 | 46 | if ( $this->hasOption( 'check-syntax' ) ) { |
49 | 47 | $this->checkSyntax(); |
50 | 48 | } |
51 | 49 | |
52 | | - if ( $wgDBtype != 'sqlite' ) { |
| 50 | + $this->db = wfGetDB( DB_MASTER ); |
| 51 | + |
| 52 | + if ( $this->db->getType() != 'sqlite' ) { |
53 | 53 | $this->error( "This maintenance script requires a SQLite database.\n" ); |
54 | 54 | return; |
55 | 55 | } |
56 | 56 | |
57 | | - $this->db = wfGetDB( DB_MASTER ); |
58 | | - |
59 | 57 | if ( $this->hasOption( 'vacuum' ) ) { |
60 | 58 | $this->vacuum(); |
61 | 59 | } |