Update wfGetDB calls in Maintenance scripts to use getDB()
authorReedy <reedy@wikimedia.org>
Thu, 31 Dec 2015 00:07:37 +0000 (00:07 +0000)
committerFlorianschmidtwelzow <florian.schmidt.stargatewissen@gmail.com>
Sat, 2 Jan 2016 16:58:23 +0000 (16:58 +0000)
Change-Id: I9ad6745d84506b736dae94747256caac89715899

83 files changed:
maintenance/archives/upgradeLogging.php
maintenance/attachLatest.php
maintenance/benchmarks/bench_delete_truncate.php
maintenance/benchmarks/benchmarkParse.php
maintenance/checkBadRedirects.php
maintenance/checkImages.php
maintenance/checkUsernames.php
maintenance/cleanupAncientTables.php
maintenance/cleanupBlocks.php
maintenance/cleanupImages.php
maintenance/cleanupRemovedModules.php
maintenance/cleanupSpam.php
maintenance/cleanupTable.inc
maintenance/cleanupTitles.php
maintenance/cleanupWatchlist.php
maintenance/clearInterwikiCache.php
maintenance/convertLinks.php
maintenance/convertUserOptions.php
maintenance/deleteBatch.php
maintenance/deleteDefaultMessages.php
maintenance/deleteEqualMessages.php
maintenance/deleteOldRevisions.php
maintenance/deleteOrphanedRevisions.php
maintenance/deleteRevision.php
maintenance/deleteSelfExternals.php
maintenance/dumpLinks.php
maintenance/dumpUploads.php
maintenance/eraseArchivedFile.php
maintenance/fetchText.php
maintenance/fixDefaultJsonContentPages.php
maintenance/fixDoubleRedirects.php
maintenance/fixExtLinksProtocolRelative.php
maintenance/fixTimestamps.php
maintenance/fixUserRegistration.php
maintenance/generateSitemap.php
maintenance/getSlaveServer.php
maintenance/getText.php
maintenance/importDump.php
maintenance/initEditCount.php
maintenance/initSiteStats.php
maintenance/migrateUserGroup.php
maintenance/moveBatch.php
maintenance/namespaceDupes.php
maintenance/nukeNS.php
maintenance/nukePage.php
maintenance/oracle/alterSharedConstraints.php
maintenance/orphans.php
maintenance/patchSql.php
maintenance/populateCategory.php
maintenance/populateContentModel.php
maintenance/populateFilearchiveSha1.php
maintenance/populateImageSha1.php
maintenance/populateParentId.php
maintenance/purgeList.php
maintenance/reassignEdits.php
maintenance/rebuildFileCache.php
maintenance/rebuildImages.php
maintenance/rebuildall.php
maintenance/rebuildrecentchanges.php
maintenance/rebuildtextindex.php
maintenance/refreshFileHeaders.php
maintenance/refreshImageMetadata.php
maintenance/refreshLinks.php
maintenance/removeUnusedAccounts.php
maintenance/renameDbPrefix.php
maintenance/resetUserTokens.php
maintenance/rollbackEdits.php
maintenance/runBatchedQuery.php
maintenance/showSiteStats.php
maintenance/sqlite.php
maintenance/storage/compressOld.php
maintenance/storage/dumpRev.php
maintenance/storage/fixBug20757.php
maintenance/storage/orphanStats.php
maintenance/storage/storageTypeStats.php
maintenance/storage/testCompression.php
maintenance/tidyUpBug37714.php
maintenance/update.php
maintenance/updateArticleCount.php
maintenance/updateDoubleWidthSearch.php
maintenance/updateRestrictions.php
maintenance/updateSearchIndex.php
maintenance/updateSpecialPages.php

index aeadc93..d5b98b5 100644 (file)
@@ -39,7 +39,7 @@ class UpdateLogging {
        public $minTs = false;
 
        function execute() {
-               $this->dbw = wfGetDB( DB_MASTER );
+               $this->dbw = $this->getDB( DB_MASTER );
                $logging = $this->dbw->tableName( 'logging' );
                $logging_1_10 = $this->dbw->tableName( 'logging_1_10' );
                $logging_pre_1_10 = $this->dbw->tableName( 'logging_pre_1_10' );
index fba6b92..a2ea554 100644 (file)
@@ -43,7 +43,7 @@ class AttachLatest extends Maintenance {
 
        public function execute() {
                $this->output( "Looking for pages with page_latest set to 0...\n" );
-               $dbw = wfGetDB( DB_MASTER );
+               $dbw = $this->getDB( DB_MASTER );
                $conds = array( 'page_latest' => 0 );
                if ( $this->hasOption( 'regenerate-all' ) ) {
                        $conds = '';
index 8ae4f03..572c548 100644 (file)
@@ -35,7 +35,7 @@ class BenchmarkDeleteTruncate extends Benchmarker {
        }
 
        public function execute() {
-               $dbw = wfGetDB( DB_MASTER );
+               $dbw = $this->getDB( DB_MASTER );
 
                $test = $dbw->tableName( 'test' );
                $dbw->query( "CREATE TABLE IF NOT EXISTS /*_*/$test (
index ce38dad..b850e63 100644 (file)
@@ -118,7 +118,7 @@ class BenchmarkParse extends Maintenance {
         * @return bool|string Revision ID, or false if not found or error
         */
        function getRevIdForTime( Title $title, $timestamp ) {
-               $dbr = wfGetDB( DB_SLAVE );
+               $dbr = $this->getDB( DB_SLAVE );
 
                $id = $dbr->selectField(
                        array( 'revision', 'page' ),
index fec9291..500fc35 100644 (file)
@@ -36,7 +36,7 @@ class CheckBadRedirects extends Maintenance {
 
        public function execute() {
                $this->output( "Fetching redirects...\n" );
-               $dbr = wfGetDB( DB_SLAVE );
+               $dbr = $this->getDB( DB_SLAVE );
                $result = $dbr->select(
                        array( 'page' ),
                        array( 'page_namespace', 'page_title', 'page_latest' ),
index 0364db2..9761927 100644 (file)
@@ -37,7 +37,7 @@ class CheckImages extends Maintenance {
 
        public function execute() {
                $start = '';
-               $dbr = wfGetDB( DB_SLAVE );
+               $dbr = $this->getDB( DB_SLAVE );
 
                $numImages = 0;
                $numGood = 0;
index a64bc49..6f4d170 100644 (file)
@@ -40,7 +40,7 @@ class CheckUsernames extends Maintenance {
        }
 
        function execute() {
-               $dbr = wfGetDB( DB_SLAVE );
+               $dbr = $this->getDB( DB_SLAVE );
 
                $maxUserId = 0;
                do {
index 2dbf8bc..f1467d5 100644 (file)
@@ -46,7 +46,7 @@ class CleanupAncientTables extends Maintenance {
                        );
                }
 
-               $db = wfGetDB( DB_MASTER );
+               $db = $this->getDB( DB_MASTER );
                $ancientTables = array(
                        'blobs', // 1.4
                        'brokenlinks', // 1.4
index 1736203..437abe9 100644 (file)
@@ -38,7 +38,7 @@ class CleanupBlocks extends Maintenance {
        }
 
        public function execute() {
-               $db = wfGetDB( DB_MASTER );
+               $db = $this->getDB( DB_MASTER );
 
                $max = $db->selectField( 'ipblocks', 'MAX(ipb_user)' );
 
index 5baa8d3..ab2d808 100644 (file)
@@ -102,7 +102,7 @@ class ImageCleanup extends TableCleanup {
                        $this->output( "DRY RUN: would delete bogus row '$name'\n" );
                } else {
                        $this->output( "deleting bogus row '$name'\n" );
-                       $db = wfGetDB( DB_MASTER );
+                       $db = $this->getDB( DB_MASTER );
                        $db->delete( 'image',
                                array( 'img_name' => $name ),
                                __METHOD__ );
@@ -139,7 +139,7 @@ class ImageCleanup extends TableCleanup {
                        return;
                }
 
-               $db = wfGetDB( DB_MASTER );
+               $db = $this->getDB( DB_MASTER );
 
                /*
                 * To prevent key collisions in the update() statements below,
index 68f57a3..810fad9 100644 (file)
@@ -39,7 +39,7 @@ class CleanupRemovedModules extends Maintenance {
        }
 
        public function execute() {
-               $dbw = wfGetDB( DB_MASTER );
+               $dbw = $this->getDB( DB_MASTER );
                $rl = new ResourceLoader( ConfigFactory::getDefaultInstance()->makeConfig( 'main' ) );
                $moduleNames = $rl->getModuleNames();
                $moduleList = implode( ', ', array_map( array( $dbw, 'addQuotes' ), $moduleNames ) );
index e6471dd..b43ce81 100644 (file)
@@ -64,7 +64,7 @@ class CleanupSpam extends Maintenance {
                        $this->output( "Finding spam on " . count( $wgLocalDatabases ) . " wikis\n" );
                        $found = false;
                        foreach ( $wgLocalDatabases as $wikiID ) {
-                               $dbr = wfGetDB( DB_SLAVE, array(), $wikiID );
+                               $dbr = $this->getDB( DB_SLAVE, array(), $wikiID );
 
                                $count = $dbr->selectField( 'externallinks', 'COUNT(*)',
                                        array( 'el_index' . $dbr->buildLike( $like ) ), __METHOD__ );
@@ -83,7 +83,7 @@ class CleanupSpam extends Maintenance {
                } else {
                        // Clean up spam on this wiki
 
-                       $dbr = wfGetDB( DB_SLAVE );
+                       $dbr = $this->getDB( DB_SLAVE );
                        $res = $dbr->select( 'externallinks', array( 'DISTINCT el_from' ),
                                array( 'el_index' . $dbr->buildLike( $like ) ), __METHOD__ );
                        $count = $dbr->numRows( $res );
@@ -120,7 +120,7 @@ class CleanupSpam extends Maintenance {
                        // This happens e.g. when a link comes from a template rather than the page itself
                        $this->output( "False match\n" );
                } else {
-                       $dbw = wfGetDB( DB_MASTER );
+                       $dbw = $this->getDB( DB_MASTER );
                        $this->beginTransaction( $dbw, __METHOD__ );
                        $page = WikiPage::factory( $title );
                        if ( $rev ) {
index 74073bc..0ddaf33 100644 (file)
@@ -106,7 +106,7 @@ class TableCleanup extends Maintenance {
         * @throws MWException
         */
        public function runTable( $params ) {
-               $dbr = wfGetDB( DB_SLAVE );
+               $dbr = $this->getDB( DB_SLAVE );
 
                if ( array_diff( array_keys( $params ),
                        array( 'table', 'conds', 'index', 'callback' ) )
index 1eba303..07df1b1 100644 (file)
@@ -78,7 +78,7 @@ class TitleCleanup extends TableCleanup {
        protected function fileExists( $name ) {
                // XXX: Doesn't actually check for file existence, just presence of image record.
                // This is reasonable, since cleanupImages.php only iterates over the image table.
-               $dbr = wfGetDB( DB_SLAVE );
+               $dbr = $this->getDB( DB_SLAVE );
                $row = $dbr->selectRow( 'image', array( 'img_name' ), array( 'img_name' => $name ), __METHOD__ );
 
                return $row !== false;
@@ -118,7 +118,7 @@ class TitleCleanup extends TableCleanup {
                } else {
                        $this->output( "renaming $row->page_id ($row->page_namespace," .
                                "'$row->page_title') to ($row->page_namespace,'$dest')\n" );
-                       $dbw = wfGetDB( DB_MASTER );
+                       $dbw = $this->getDB( DB_MASTER );
                        $dbw->update( 'page',
                                array( 'page_title' => $dest ),
                                array( 'page_id' => $row->page_id ),
@@ -171,7 +171,7 @@ class TitleCleanup extends TableCleanup {
                } else {
                        $this->output( "renaming $row->page_id ($row->page_namespace," .
                                "'$row->page_title') to ($ns,'$dest')\n" );
-                       $dbw = wfGetDB( DB_MASTER );
+                       $dbw = $this->getDB( DB_MASTER );
                        $dbw->update( 'page',
                                array(
                                        'page_namespace' => $ns,
index eb7d7b1..16f7b61 100644 (file)
@@ -77,7 +77,7 @@ class WatchlistCleanup extends TableCleanup {
 
        private function removeWatch( $row ) {
                if ( !$this->dryrun && $this->hasOption( 'fix' ) ) {
-                       $dbw = wfGetDB( DB_MASTER );
+                       $dbw = $this->getDB( DB_MASTER );
                        $dbw->delete(
                                'watchlist', array(
                                'wl_user' => $row->wl_user,
index 80c9004..6a6527f 100644 (file)
@@ -37,7 +37,7 @@ class ClearInterwikiCache extends Maintenance {
 
        public function execute() {
                global $wgLocalDatabases, $wgMemc;
-               $dbr = wfGetDB( DB_SLAVE );
+               $dbr = $this->getDB( DB_SLAVE );
                $res = $dbr->select( 'interwiki', array( 'iw_prefix' ), false );
                $prefixes = array();
                foreach ( $res as $row ) {
index c3ad46a..15ca14b 100644 (file)
@@ -66,7 +66,7 @@ class ConvertLinks extends Maintenance {
        }
 
        public function execute() {
-               $dbw = wfGetDB( DB_MASTER );
+               $dbw = $this->getDB( DB_MASTER );
 
                $type = $dbw->getType();
                if ( $type != 'mysql' ) {
@@ -267,7 +267,7 @@ class ConvertLinks extends Maintenance {
        }
 
        private function createTempTable() {
-               $dbConn = wfGetDB( DB_MASTER );
+               $dbConn = $this->getDB( DB_MASTER );
 
                if ( !( $dbConn->isOpen() ) ) {
                        $this->output( "Opening connection to database failed.\n" );
index 1542a8c..11768c8 100644 (file)
@@ -41,7 +41,7 @@ class ConvertUserOptions extends Maintenance {
        public function execute() {
                $this->output( "...batch conversion of user_options: " );
                $id = 0;
-               $dbw = wfGetDB( DB_MASTER );
+               $dbw = $this->getDB( DB_MASTER );
 
                if ( !$dbw->fieldExists( 'user', 'user_options', __METHOD__ ) ) {
                        $this->output( "nothing to migrate. " );
index a3b1561..6c89e67 100644 (file)
@@ -80,7 +80,7 @@ class DeleteBatch extends Maintenance {
                        $this->error( "Unable to read file, exiting", true );
                }
 
-               $dbw = wfGetDB( DB_MASTER );
+               $dbw = $this->getDB( DB_MASTER );
 
                # Handle each entry
                // @codingStandardsIgnoreStart Ignore Generic.CodeAnalysis.ForLoopWithTestFunctionCall.NotAllowed
index a1c0f61..a5c6199 100644 (file)
@@ -41,7 +41,7 @@ class DeleteDefaultMessages extends Maintenance {
                global $wgUser;
 
                $this->output( "Checking existence of old default messages..." );
-               $dbr = wfGetDB( DB_SLAVE );
+               $dbr = $this->getDB( DB_SLAVE );
                $res = $dbr->select( array( 'page', 'revision' ),
                        array( 'page_namespace', 'page_title' ),
                        array(
@@ -69,7 +69,7 @@ class DeleteDefaultMessages extends Maintenance {
 
                # Handle deletion
                $this->output( "\n...deleting old default messages (this may take a long time!)...", 'msg' );
-               $dbw = wfGetDB( DB_MASTER );
+               $dbw = $this->getDB( DB_MASTER );
 
                foreach ( $res as $row ) {
                        wfWaitForSlaves();
index de5c5e2..e7bb866 100644 (file)
@@ -174,7 +174,7 @@ class DeleteEqualMessages extends Maintenance {
 
                // Handle deletion
                $this->output( "\n...deleting equal messages (this may take a long time!)..." );
-               $dbw = wfGetDB( DB_MASTER );
+               $dbw = $this->getDB( DB_MASTER );
                foreach ( $messageInfo['results'] as $result ) {
                        wfWaitForSlaves();
                        $dbw->ping();
index 0c06ec5..f411148 100644 (file)
@@ -45,7 +45,7 @@ class DeleteOldRevisions extends Maintenance {
        function doDelete( $delete = false, $args = array() ) {
 
                # Data should come off the master, wrapped in a transaction
-               $dbw = wfGetDB( DB_MASTER );
+               $dbw = $this->getDB( DB_MASTER );
                $this->beginTransaction( $dbw, __METHOD__ );
 
                $pageConds = array();
index 776d345..3d5c1a4 100644 (file)
@@ -43,7 +43,7 @@ class DeleteOrphanedRevisions extends Maintenance {
 
                $report = $this->hasOption( 'report' );
 
-               $dbw = wfGetDB( DB_MASTER );
+               $dbw = $this->getDB( DB_MASTER );
                $this->beginTransaction( $dbw, __METHOD__ );
                list( $page, $revision ) = $dbw->tableNamesN( 'page', 'revision' );
 
index 818ee36..6cda784 100644 (file)
@@ -43,7 +43,7 @@ class DeleteRevision extends Maintenance {
 
                $this->output( "Deleting revision(s) " . implode( ',', $this->mArgs ) .
                        " from " . wfWikiID() . "...\n" );
-               $dbw = wfGetDB( DB_MASTER );
+               $dbw = $this->getDB( DB_MASTER );
 
                $affected = 0;
                foreach ( $this->mArgs as $revID ) {
index a397663..f9bb416 100644 (file)
@@ -39,7 +39,7 @@ class DeleteSelfExternals extends Maintenance {
        public function execute() {
                global $wgServer;
                $this->output( "Deleting self externals from $wgServer\n" );
-               $db = wfGetDB( DB_MASTER );
+               $db = $this->getDB( DB_MASTER );
                while ( 1 ) {
                        wfWaitForSlaves();
                        $this->commitTransaction( $db, __METHOD__ );
index 888c2dc..74b500a 100644 (file)
@@ -44,7 +44,7 @@ class DumpLinks extends Maintenance {
        }
 
        public function execute() {
-               $dbr = wfGetDB( DB_SLAVE );
+               $dbr = $this->getDB( DB_SLAVE );
                $result = $dbr->select( array( 'pagelinks', 'page' ),
                        array(
                                'page_id',
index 9d53f07..026ac02 100644 (file)
@@ -76,7 +76,7 @@ By default, outputs relative paths against the parent directory of \$wgUploadDir
         * @param bool $shared True to pass shared-dir settings to hash func
         */
        function fetchUsed( $shared ) {
-               $dbr = wfGetDB( DB_SLAVE );
+               $dbr = $this->getDB( DB_SLAVE );
                $image = $dbr->tableName( 'image' );
                $imagelinks = $dbr->tableName( 'imagelinks' );
 
@@ -97,7 +97,7 @@ By default, outputs relative paths against the parent directory of \$wgUploadDir
         * @param bool $shared True to pass shared-dir settings to hash func
         */
        function fetchLocal( $shared ) {
-               $dbr = wfGetDB( DB_SLAVE );
+               $dbr = $this->getDB( DB_SLAVE );
                $result = $dbr->select( 'image',
                        array( 'img_name' ),
                        '',
index 8fdcef3..69a95e2 100644 (file)
@@ -55,7 +55,7 @@ class EraseArchivedFile extends Maintenance {
                        }
                        $afile = false;
                } else { // specified version
-                       $dbw = wfGetDB( DB_MASTER );
+                       $dbw = $this->getDB( DB_MASTER );
                        $row = $dbw->selectRow( 'filearchive', '*',
                                array( 'fa_storage_group' => 'deleted', 'fa_storage_key' => $filekey ),
                                __METHOD__ );
@@ -85,7 +85,7 @@ class EraseArchivedFile extends Maintenance {
        }
 
        protected function scrubAllVersions( $name ) {
-               $dbw = wfGetDB( DB_MASTER );
+               $dbw = $this->getDB( DB_MASTER );
                $res = $dbw->select( 'filearchive', '*',
                        array( 'fa_name' => $name, 'fa_storage_group' => 'deleted' ),
                        __METHOD__ );
index 983b772..cf12838 100644 (file)
@@ -48,7 +48,7 @@ class FetchText extends Maintenance {
         * note that the text string itself is *not* followed by newline
         */
        public function execute() {
-               $db = wfGetDB( DB_SLAVE );
+               $db = $this->getDB( DB_SLAVE );
                $stdin = $this->getStdin();
                while ( !feof( $stdin ) ) {
                        $line = fgets( $stdin );
index 1265891..25ec342 100644 (file)
@@ -47,7 +47,7 @@ class FixDefaultJsonContentPages extends LoggedUpdateMaintenance {
                        return true;
                }
 
-               $dbr = wfGetDB( DB_SLAVE );
+               $dbr = $this->getDB( DB_SLAVE );
                $namespaces = array(
                        NS_MEDIAWIKI => $dbr->buildLike( $dbr->anyString(), '.json' ),
                        NS_USER => $dbr->buildLike( $dbr->anyString(), '/', $dbr->anyString(), '.json' ),
@@ -80,7 +80,7 @@ class FixDefaultJsonContentPages extends LoggedUpdateMaintenance {
                $this->output( "Processing {$title} ({$row->page_id})...\n" );
                $rev = Revision::newFromTitle( $title );
                $content = $rev->getContent( Revision::RAW );
-               $dbw = wfGetDB( DB_MASTER );
+               $dbw = $this->getDB( DB_MASTER );
                if ( $content instanceof JsonContent ) {
                        if ( $content->isValid() ) {
                                // Yay, actually JSON. We need to just change the
index 9568284..ca551f8 100644 (file)
@@ -54,7 +54,7 @@ class FixDoubleRedirects extends Maintenance {
                        $title = null;
                }
 
-               $dbr = wfGetDB( DB_SLAVE );
+               $dbr = $this->getDB( DB_SLAVE );
 
                // See also SpecialDoubleRedirects
                $tables = array(
index 0c60e62..a44f8e5 100644 (file)
@@ -47,7 +47,7 @@ class FixExtLinksProtocolRelative extends LoggedUpdateMaintenance {
        }
 
        protected function doDBUpdates() {
-               $db = wfGetDB( DB_MASTER );
+               $db = $this->getDB( DB_MASTER );
                if ( !$db->tableExists( 'externallinks' ) ) {
                        $this->error( "externallinks table does not exist" );
 
index 5431cf2..c2a748c 100644 (file)
@@ -49,7 +49,7 @@ class FixTimestamps extends Maintenance {
                $grace = 60; // maximum normal clock offset
 
                # Find bounding revision IDs
-               $dbw = wfGetDB( DB_MASTER );
+               $dbw = $this->getDB( DB_MASTER );
                $revisionTable = $dbw->tableName( 'revision' );
                $res = $dbw->query( "SELECT MIN(rev_id) as minrev, MAX(rev_id) as maxrev FROM $revisionTable " .
                        "WHERE rev_timestamp BETWEEN '{$start}' AND '{$end}'", __METHOD__ );
index 40e0915..d09760b 100644 (file)
@@ -37,7 +37,7 @@ class FixUserRegistration extends Maintenance {
        }
 
        public function execute() {
-               $dbw = wfGetDB( DB_MASTER );
+               $dbw = $this->getDB( DB_MASTER );
 
                $lastId = 0;
                do {
index 12711ea..c40d0ce 100644 (file)
@@ -196,7 +196,7 @@ class GenerateSitemap extends Maintenance {
                $this->identifier = $this->getOption( 'identifier', wfWikiID() );
                $this->compress = $this->getOption( 'compress', 'yes' ) !== 'no';
                $this->skipRedirects = $this->getOption( 'skip-redirects', false ) !== false;
-               $this->dbr = wfGetDB( DB_SLAVE );
+               $this->dbr = $this->getDB( DB_SLAVE );
                $this->generateNamespaces();
                $this->timestamp = wfTimestamp( TS_ISO_8601, wfTimestampNow() );
                $this->findex = fopen( "{$this->fspath}sitemap-index-{$this->identifier}.xml", 'wb' );
index 68c1943..c858c38 100644 (file)
@@ -40,7 +40,7 @@ class GetSlaveServer extends Maintenance {
                if ( $wgAllDBsAreLocalhost ) {
                        $host = 'localhost';
                } elseif ( $this->hasOption( 'group' ) ) {
-                       $db = wfGetDB( DB_SLAVE, $this->getOption( 'group' ) );
+                       $db = $this->getDB( DB_SLAVE, $this->getOption( 'group' ) );
                        $host = $db->getServer();
                } else {
                        $lb = wfGetLB();
index 7d7c1cc..c4b8cc9 100644 (file)
@@ -39,8 +39,6 @@ class GetTextMaint extends Maintenance {
        }
 
        public function execute() {
-               $this->db = wfGetDB( DB_SLAVE );
-
                $titleText = $this->getArg( 0 );
                $title = Title::newFromText( $titleText );
                if ( !$title ) {
index 43e5060..5806ffc 100644 (file)
@@ -201,7 +201,7 @@ TEXT;
                        if ( !$this->dryRun ) {
                                // bluuuh hack
                                // call_user_func( $this->uploadCallback, $revision );
-                               $dbw = wfGetDB( DB_MASTER );
+                               $dbw = $this->getDB( DB_MASTER );
 
                                return $dbw->deadlockLoop( array( $revision, 'importUpload' ) );
                        }
index 7c6e7d4..dee5db8 100644 (file)
@@ -39,7 +39,7 @@ in the load balancer, usually indicating a replication environment.' );
        }
 
        public function execute() {
-               $dbw = wfGetDB( DB_MASTER );
+               $dbw = $this->getDB( DB_MASTER );
                $user = $dbw->tableName( 'user' );
                $revision = $dbw->tableName( 'revision' );
 
@@ -58,7 +58,7 @@ in the load balancer, usually indicating a replication environment.' );
                if ( $backgroundMode ) {
                        $this->output( "Using replication-friendly background mode...\n" );
 
-                       $dbr = wfGetDB( DB_SLAVE );
+                       $dbr = $this->getDB( DB_SLAVE );
                        $chunkSize = 100;
                        $lastUser = $dbr->selectField( 'user', 'MAX(user_id)', '', __METHOD__ );
 
index cac33ec..8d26063 100644 (file)
@@ -67,7 +67,7 @@ class InitSiteStats extends Maintenance {
 
                if ( $this->hasOption( 'active' ) ) {
                        $this->output( "\nCounting and updating active users..." );
-                       $active = SiteStatsUpdate::cacheUpdate( wfGetDB( DB_MASTER ) );
+                       $active = SiteStatsUpdate::cacheUpdate( $this->getDB( DB_MASTER ) );
                        $this->output( "{$active}\n" );
                }
 
index a0c41fd..dc20eee 100644 (file)
@@ -41,7 +41,7 @@ class MigrateUserGroup extends Maintenance {
                $count = 0;
                $oldGroup = $this->getArg( 0 );
                $newGroup = $this->getArg( 1 );
-               $dbw = wfGetDB( DB_MASTER );
+               $dbw = $this->getDB( DB_MASTER );
                $start = $dbw->selectField( 'user_groups', 'MIN(ug_user)',
                        array( 'ug_group' => $oldGroup ), __FUNCTION__ );
                $end = $dbw->selectField( 'user_groups', 'MAX(ug_user)',
index 8a81fdd..43d4d25 100644 (file)
@@ -85,7 +85,7 @@ class MoveBatch extends Maintenance {
                }
 
                # Setup complete, now start
-               $dbw = wfGetDB( DB_MASTER );
+               $dbw = $this->getDB( DB_MASTER );
                // @codingStandardsIgnoreStart Ignore avoid function calls in a FOR loop test part warning
                for ( $linenum = 1; !feof( $file ); $linenum++ ) {
                        // @codingStandardsIgnoreEnd
index f67005d..6e5cd38 100644 (file)
@@ -67,7 +67,7 @@ class NamespaceConflictChecker extends Maintenance {
        }
 
        public function execute() {
-               $this->db = wfGetDB( DB_MASTER );
+               $this->db = $this->getDB( DB_MASTER );
 
                $options = array(
                        'fix' => $this->hasOption( 'fix' ),
index 04e2673..0f2dbf6 100644 (file)
@@ -54,7 +54,7 @@ class NukeNS extends Maintenance {
                $ns = $this->getOption( 'ns', NS_MEDIAWIKI );
                $delete = $this->getOption( 'delete', false );
                $all = $this->getOption( 'all', false );
-               $dbw = wfGetDB( DB_MASTER );
+               $dbw = $this->getDB( DB_MASTER );
                $this->beginTransaction( $dbw, __METHOD__ );
 
                $tbl_pag = $dbw->tableName( 'page' );
index 94e3409..dc45520 100644 (file)
@@ -43,7 +43,7 @@ class NukePage extends Maintenance {
                $name = $this->getArg();
                $delete = $this->getOption( 'delete', false );
 
-               $dbw = wfGetDB( DB_MASTER );
+               $dbw = $this->getDB( DB_MASTER );
                $this->beginTransaction( $dbw, __METHOD__ );
 
                $tbl_pag = $dbw->tableName( 'page' );
@@ -104,7 +104,7 @@ class NukePage extends Maintenance {
        }
 
        public function deleteRevisions( $ids ) {
-               $dbw = wfGetDB( DB_MASTER );
+               $dbw = $this->getDB( DB_MASTER );
                $this->beginTransaction( $dbw, __METHOD__ );
 
                $tbl_rev = $dbw->tableName( 'revision' );
index eea6f7b..67e5ded 100644 (file)
@@ -48,7 +48,7 @@ class AlterSharedConstraints extends Maintenance {
                        return;
                }
 
-               $dbw = wfGetDB( DB_MASTER );
+               $dbw = $this->getDB( DB_MASTER );
                foreach ( $wgSharedTables as $table ) {
                        $stable = $dbw->tableNameInternal( $table );
                        if ( $wgSharedPrefix != null ) {
index 7e27107..3c5566f 100644 (file)
@@ -71,7 +71,7 @@ class Orphans extends Maintenance {
         * @param bool $fix Whether to fix broken revisions when found
         */
        private function checkOrphans( $fix ) {
-               $dbw = wfGetDB( DB_MASTER );
+               $dbw = $this->getDB( DB_MASTER );
                $page = $dbw->tableName( 'page' );
                $revision = $dbw->tableName( 'revision' );
 
@@ -129,7 +129,7 @@ class Orphans extends Maintenance {
         *       but valid revisions do exist)
         */
        private function checkWidows( $fix ) {
-               $dbw = wfGetDB( DB_MASTER );
+               $dbw = $this->getDB( DB_MASTER );
                $page = $dbw->tableName( 'page' );
                $revision = $dbw->tableName( 'revision' );
 
@@ -175,7 +175,7 @@ class Orphans extends Maintenance {
         * @param bool $fix Whether to fix broken entries
         */
        private function checkSeparation( $fix ) {
-               $dbw = wfGetDB( DB_MASTER );
+               $dbw = $this->getDB( DB_MASTER );
                $page = $dbw->tableName( 'page' );
                $revision = $dbw->tableName( 'revision' );
 
index 5d9fc1b..1f77bdb 100644 (file)
@@ -44,7 +44,7 @@ class PatchSql extends Maintenance {
        }
 
        public function execute() {
-               $dbw = wfGetDB( DB_MASTER );
+               $dbw = $this->getDB( DB_MASTER );
                foreach ( $this->mArgs as $arg ) {
                        $files = array(
                                $arg,
index 65d272b..481e073 100644 (file)
@@ -71,7 +71,7 @@ TEXT;
                $throttle = $this->getOption( 'throttle', 0 );
                $force = $this->getOption( 'force', false );
 
-               $dbw = wfGetDB( DB_MASTER );
+               $dbw = $this->getDB( DB_MASTER );
 
                if ( !$force ) {
                        $row = $dbw->selectRow(
index 7bca0ec..4f9c7ae 100644 (file)
@@ -37,7 +37,7 @@ class PopulateContentModel extends Maintenance {
        }
 
        public function execute() {
-               $dbw = wfGetDB( DB_MASTER );
+               $dbw = $this->getDB( DB_MASTER );
                $ns = $this->getOption( 'ns' );
                if ( !ctype_digit( $ns ) && $ns !== 'all' ) {
                        $this->error( 'Invalid namespace', 1 );
index a3099f9..5a67262 100644 (file)
@@ -45,7 +45,7 @@ class PopulateFilearchiveSha1 extends LoggedUpdateMaintenance {
 
        public function doDBUpdates() {
                $startTime = microtime( true );
-               $dbw = wfGetDB( DB_MASTER );
+               $dbw = $this->getDB( DB_MASTER );
                $table = 'filearchive';
                $conds = array( 'fa_sha1' => '', 'fa_storage_key IS NOT NULL' );
 
index e9123aa..cc52239 100644 (file)
@@ -67,7 +67,7 @@ class PopulateImageSha1 extends LoggedUpdateMaintenance {
                $isRegen = ( $force || $file != '' ); // forced recalculation?
 
                $t = -microtime( true );
-               $dbw = wfGetDB( DB_MASTER );
+               $dbw = $this->getDB( DB_MASTER );
                if ( $file != '' ) {
                        $res = $dbw->select(
                                'image',
index 686d9f2..9baf28e 100644 (file)
@@ -46,7 +46,7 @@ class PopulateParentId extends LoggedUpdateMaintenance {
        }
 
        protected function doDBUpdates() {
-               $db = wfGetDB( DB_MASTER );
+               $db = $this->getDB( DB_MASTER );
                if ( !$db->tableExists( 'revision' ) ) {
                        $this->error( "revision table does not exist" );
 
index 31ea5d0..9963cbf 100644 (file)
@@ -86,7 +86,7 @@ class PurgeList extends Maintenance {
         * @param int|bool $namespace
         */
        private function purgeNamespace( $namespace = false ) {
-               $dbr = wfGetDB( DB_SLAVE );
+               $dbr = $this->getDB( DB_SLAVE );
                $startId = 0;
                if ( $namespace === false ) {
                        $conds = array();
index 4d1c537..e68937a 100644 (file)
@@ -74,7 +74,7 @@ class ReassignEdits extends Maintenance {
         * @return int Number of entries changed, or that would be changed
         */
        private function doReassignEdits( &$from, &$to, $rc = false, $report = false ) {
-               $dbw = wfGetDB( DB_MASTER );
+               $dbw = $this->getDB( DB_MASTER );
                $this->beginTransaction( $dbw, __METHOD__ );
 
                # Count things
index 4147491..e07bf03 100644 (file)
@@ -70,7 +70,7 @@ class RebuildFileCache extends Maintenance {
 
                $this->output( "Building content page file cache from page {$start}!\n" );
 
-               $dbr = wfGetDB( DB_SLAVE );
+               $dbr = $this->getDB( DB_SLAVE );
                $overwrite = $this->getOption( 'overwrite', false );
                $start = ( $start > 0 )
                        ? $start
@@ -89,7 +89,7 @@ class RebuildFileCache extends Maintenance {
                $blockStart = $start;
                $blockEnd = $start + $this->mBatchSize - 1;
 
-               $dbw = wfGetDB( DB_MASTER );
+               $dbw = $this->getDB( DB_MASTER );
                // Go through each page and save the output
                while ( $blockEnd <= $end ) {
                        // Get the pages
index b1bb353..1b0a27d 100644 (file)
@@ -58,7 +58,7 @@ class ImageBuilder extends Maintenance {
        }
 
        public function execute() {
-               $this->dbw = wfGetDB( DB_MASTER );
+               $this->dbw = $this->getDB( DB_MASTER );
                $this->dryrun = $this->hasOption( 'dry-run' );
                if ( $this->dryrun ) {
                        $GLOBALS['wgReadOnly'] = 'Dry run mode, image upgrades are suppressed';
@@ -127,7 +127,7 @@ class ImageBuilder extends Maintenance {
                $this->init( $count, $table );
                $this->output( "Processing $table...\n" );
 
-               $result = wfGetDB( DB_SLAVE )->select( $table, '*', array(), __METHOD__ );
+               $result = $this->getDB( DB_SLAVE )->select( $table, '*', array(), __METHOD__ );
 
                foreach ( $result as $row ) {
                        $update = call_user_func( $callback, $row, null );
index eeee9c2..4ff873e 100644 (file)
@@ -41,7 +41,7 @@ class RebuildAll extends Maintenance {
 
        public function execute() {
                // Rebuild the text index
-               if ( wfGetDB( DB_SLAVE )->getType() != 'postgres' ) {
+               if ( $this->getDB( 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' );
index cdaa777..b6421f3 100644 (file)
@@ -49,7 +49,7 @@ class RebuildRecentchanges extends Maintenance {
         * Rebuild pass 1: Insert `recentchanges` entries for page revisions.
         */
        private function rebuildRecentChangesTablePass1() {
-               $dbw = wfGetDB( DB_MASTER );
+               $dbw = $this->getDB( DB_MASTER );
 
                $dbw->delete( 'recentchanges', '*' );
 
@@ -103,7 +103,7 @@ class RebuildRecentchanges extends Maintenance {
         * (rc_last_oldid, rc_new etc.) and size differences (rc_old_len, rc_new_len).
         */
        private function rebuildRecentChangesTablePass2() {
-               $dbw = wfGetDB( DB_MASTER );
+               $dbw = $this->getDB( DB_MASTER );
                list( $recentchanges, $revision ) = $dbw->tableNamesN( 'recentchanges', 'revision' );
 
                $this->output( "Updating links and size differences...\n" );
@@ -169,7 +169,7 @@ class RebuildRecentchanges extends Maintenance {
         * Rebuild pass 3: Insert `recentchanges` entries for action logs.
         */
        private function rebuildRecentChangesTablePass3() {
-               $dbw = wfGetDB( DB_MASTER );
+               $dbw = $this->getDB( DB_MASTER );
 
                $this->output( "Loading from user, page, and logging tables...\n" );
 
@@ -224,7 +224,7 @@ class RebuildRecentchanges extends Maintenance {
        private function rebuildRecentChangesTablePass4() {
                global $wgUseRCPatrol;
 
-               $dbw = wfGetDB( DB_MASTER );
+               $dbw = $this->getDB( DB_MASTER );
 
                list( $recentchanges, $usergroups, $user ) =
                        $dbw->tableNamesN( 'recentchanges', 'user_groups', 'user' );
index e29d89e..e8d59bc 100644 (file)
@@ -51,12 +51,11 @@ class RebuildTextIndex extends Maintenance {
 
        public function execute() {
                // Shouldn't be needed for Postgres
-               $this->db = wfGetDB( DB_MASTER );
+               $this->db = $this->getDB( DB_MASTER );
                if ( $this->db->getType() == 'postgres' ) {
                        $this->error( "This script is not needed when using Postgres.\n", true );
                }
 
-               $this->db = wfGetDB( DB_MASTER );
                if ( $this->db->getType() == 'sqlite' ) {
                        if ( !DatabaseSqlite::getFulltextSearchModule() ) {
                                $this->error( "Your version of SQLite module for PHP doesn't "
index 8b852e3..6bc72ec 100644 (file)
@@ -47,7 +47,7 @@ class RefreshFileHeaders extends Maintenance {
                $end = str_replace( ' ', '_', $this->getOption( 'end', '' ) ); // page on img_name
 
                $count = 0;
-               $dbr = wfGetDB( DB_SLAVE );
+               $dbr = $this->getDB( DB_SLAVE );
                do {
                        $conds = array( "img_name > {$dbr->addQuotes( $start )}" );
                        if ( strlen( $end ) ) {
index 831118c..4f2341c 100644 (file)
@@ -95,7 +95,7 @@ class RefreshImageMetadata extends Maintenance {
                $leftAlone = 0;
                $error = 0;
 
-               $dbw = wfGetDB( DB_MASTER );
+               $dbw = $this->getDB( DB_MASTER );
                if ( $this->mBatchSize <= 0 ) {
                        $this->error( "Batch size is too low...", 12 );
                }
index ed16805..a0cd6a9 100644 (file)
@@ -76,7 +76,7 @@ class RefreshLinks extends Maintenance {
                global $wgParser;
 
                $reportingInterval = 100;
-               $dbr = wfGetDB( DB_SLAVE );
+               $dbr = $this->getDB( DB_SLAVE );
 
                if ( $start === null ) {
                        $start = 1;
@@ -192,7 +192,7 @@ class RefreshLinks extends Maintenance {
         */
        private function fixRedirect( $id ) {
                $page = WikiPage::newFromID( $id );
-               $dbw = wfGetDB( DB_MASTER );
+               $dbw = $this->getDB( DB_MASTER );
 
                if ( $page === null ) {
                        // This page doesn't exist (any more)
@@ -262,7 +262,7 @@ class RefreshLinks extends Maintenance {
        ) {
                wfWaitForSlaves();
                $this->output( "Deleting illegal entries from the links tables...\n" );
-               $dbr = wfGetDB( DB_SLAVE );
+               $dbr = $this->getDB( DB_SLAVE );
                do {
                        // Find the start of the next chunk. This is based only
                        // on existent page_ids.
@@ -302,8 +302,8 @@ class RefreshLinks extends Maintenance {
         * @param int $batchSize The size of deletion batches
         */
        private function dfnCheckInterval( $start = null, $end = null, $batchSize = 100 ) {
-               $dbw = wfGetDB( DB_MASTER );
-               $dbr = wfGetDB( DB_SLAVE );
+               $dbw = $this->getDB( DB_MASTER );
+               $dbr = $this->getDB( DB_SLAVE );
 
                $linksTables = array( // table name => page_id field
                        'pagelinks' => 'pl_from',
index 6416407..7937dd0 100644 (file)
@@ -45,7 +45,7 @@ class RemoveUnusedAccounts extends Maintenance {
                # Do an initial scan for inactive accounts and report the result
                $this->output( "Checking for unused user accounts...\n" );
                $del = array();
-               $dbr = wfGetDB( DB_SLAVE );
+               $dbr = $this->getDB( DB_SLAVE );
                $res = $dbr->select( 'user', array( 'user_id', 'user_name', 'user_touched' ), '', __METHOD__ );
                if ( $this->hasOption( 'ignore-groups' ) ) {
                        $excludedGroups = explode( ',', $this->getOption( 'ignore-groups' ) );
@@ -76,7 +76,7 @@ class RemoveUnusedAccounts extends Maintenance {
                # If required, go back and delete each marked account
                if ( $count > 0 && $this->hasOption( 'delete' ) ) {
                        $this->output( "\nDeleting unused accounts..." );
-                       $dbw = wfGetDB( DB_MASTER );
+                       $dbw = $this->getDB( DB_MASTER );
                        $dbw->delete( 'user', array( 'user_id' => $del ), __METHOD__ );
                        $dbw->delete( 'user_groups', array( 'ug_user' => $del ), __METHOD__ );
                        $dbw->delete( 'user_former_groups', array( 'ufg_user' => $del ), __METHOD__ );
@@ -107,7 +107,7 @@ class RemoveUnusedAccounts extends Maintenance {
         * @return bool
         */
        private function isInactiveAccount( $id, $master = false ) {
-               $dbo = wfGetDB( $master ? DB_MASTER : DB_SLAVE );
+               $dbo = $this->getDB( $master ? DB_MASTER : DB_SLAVE );
                $checks = array(
                        'revision' => 'rev',
                        'archive' => 'ar',
index ed9d1f5..2772f04 100644 (file)
@@ -71,7 +71,7 @@ class RenameDbPrefix extends Maintenance {
                $this->output( "Renaming DB prefix for tables of $wgDBname from '$old' to '$new'\n" );
                $count = 0;
 
-               $dbw = wfGetDB( DB_MASTER );
+               $dbw = $this->getDB( DB_MASTER );
                $res = $dbw->query( "SHOW TABLES " . $dbw->buildLike( $old, $dbw->anyString() ) );
                foreach ( $res as $row ) {
                        // XXX: odd syntax. MySQL outputs an oddly cased "Tables of X"
index 08be553..9c7aef2 100644 (file)
@@ -65,7 +65,7 @@ class ResetUserTokens extends Maintenance {
                }
 
                // We list user by user_id from one of the slave database
-               $dbr = wfGetDB( DB_SLAVE );
+               $dbr = $this->getDB( DB_SLAVE );
 
                $where = array();
                if ( $this->nullsOnly ) {
index 7be5a1f..7134453 100644 (file)
@@ -95,7 +95,7 @@ class RollbackEdits extends Maintenance {
         * @return array
         */
        private function getRollbackTitles( $user ) {
-               $dbr = wfGetDB( DB_SLAVE );
+               $dbr = $this->getDB( DB_SLAVE );
                $titles = array();
                $results = $dbr->select(
                        array( 'page', 'revision' ),
index af88905..3fd9e02 100644 (file)
@@ -45,7 +45,7 @@ class BatchedQueryRunner extends Maintenance {
 
                $query = $this->getArg();
                $n = 1;
-               $dbw = wfGetDB( DB_MASTER );
+               $dbw = $this->getDB( DB_MASTER );
                do {
                        $this->output( "Batch $n: " );
                        $n++;
index 370d14e..56cc573 100644 (file)
@@ -53,7 +53,7 @@ class ShowSiteStats extends Maintenance {
                );
 
                // Get cached stats from slave database
-               $dbr = wfGetDB( DB_SLAVE );
+               $dbr = $this->getDB( DB_SLAVE );
                $stats = $dbr->selectRow( 'site_stats', '*', '', __METHOD__ );
 
                // Get maximum size for each column
index b11f1c8..96a8a38 100644 (file)
@@ -59,7 +59,7 @@ class SqliteMaintenance extends Maintenance {
                        return;
                }
 
-               $this->db = wfGetDB( DB_MASTER );
+               $this->db = $this->getDB( DB_MASTER );
 
                if ( $this->db->getType() != 'sqlite' ) {
                        $this->error( "This maintenance script requires a SQLite database.\n" );
index f115bf8..b27b111 100644 (file)
@@ -151,7 +151,7 @@ class CompressOld extends Maintenance {
        private function compressOldPages( $start = 0, $extdb = '' ) {
                $chunksize = 50;
                $this->output( "Starting from old_id $start...\n" );
-               $dbw = wfGetDB( DB_MASTER );
+               $dbw = $this->getDB( DB_MASTER );
                do {
                        $res = $dbw->select(
                                'text',
@@ -192,7 +192,7 @@ class CompressOld extends Maintenance {
                        # print "Already compressed row {$row->old_id}\n";
                        return false;
                }
-               $dbw = wfGetDB( DB_MASTER );
+               $dbw = $this->getDB( DB_MASTER );
                $flags = $row->old_flags ? "{$row->old_flags},gzip" : "gzip";
                $compress = gzdeflate( $row->old_text );
 
@@ -237,8 +237,8 @@ class CompressOld extends Maintenance {
        ) {
                $loadStyle = self::LS_CHUNKED;
 
-               $dbr = wfGetDB( DB_SLAVE );
-               $dbw = wfGetDB( DB_MASTER );
+               $dbr = $this->getDB( DB_SLAVE );
+               $dbw = $this->getDB( DB_MASTER );
 
                # Set up external storage
                if ( $extdb != '' ) {
index f12bbd1..dcb76e3 100644 (file)
@@ -36,7 +36,7 @@ class DumpRev extends Maintenance {
        }
 
        public function execute() {
-               $dbr = wfGetDB( DB_SLAVE );
+               $dbr = $this->getDB( DB_SLAVE );
                $row = $dbr->selectRow(
                        array( 'text', 'revision' ),
                        array( 'old_flags', 'old_text' ),
index c6692b5..e926f56 100644 (file)
@@ -42,8 +42,8 @@ class FixBug20757 extends Maintenance {
        }
 
        function execute() {
-               $dbr = wfGetDB( DB_SLAVE );
-               $dbw = wfGetDB( DB_MASTER );
+               $dbr = $this->getDB( DB_SLAVE );
+               $dbw = $this->getDB( DB_MASTER );
 
                $dryRun = $this->getOption( 'dry-run' );
                if ( $dryRun ) {
@@ -283,7 +283,7 @@ class FixBug20757 extends Maintenance {
                                unset( $this->mapCache[$key] );
                        }
 
-                       $dbr = wfGetDB( DB_SLAVE );
+                       $dbr = $this->getDB( DB_SLAVE );
                        $map = array();
                        $res = $dbr->select( 'revision',
                                array( 'rev_id', 'rev_text_id' ),
index c5213ad..b1bf95b 100644 (file)
@@ -43,7 +43,7 @@ class OrphanStats extends Maintenance {
        }
 
        public function execute() {
-               $dbr = wfGetDB( DB_SLAVE );
+               $dbr = $this->getDB( DB_SLAVE );
                if ( !$dbr->tableExists( 'blob_orphans' ) ) {
                        $this->error( "blob_orphans doesn't seem to exist, need to run trackBlobs.php first", true );
                }
index e33057f..e156efe 100644 (file)
@@ -23,7 +23,7 @@ require_once __DIR__ . '/../Maintenance.php';
 
 class StorageTypeStats extends Maintenance {
        function execute() {
-               $dbr = wfGetDB( DB_SLAVE );
+               $dbr = $this->getDB( DB_SLAVE );
 
                $endId = $dbr->selectField( 'text', 'MAX(old_id)', false, __METHOD__ );
                if ( !$endId ) {
index f7ec662..148a9d1 100644 (file)
@@ -46,7 +46,7 @@ if ( isset( $options['limit'] ) ) {
 }
 $type = isset( $options['type'] ) ? $options['type'] : 'ConcatenatedGzipHistoryBlob';
 
-$dbr = wfGetDB( DB_SLAVE );
+$dbr = $this->getDB( DB_SLAVE );
 $res = $dbr->select(
        array( 'page', 'revision', 'text' ),
        '*',
index 1ad9c7e..eac7b3f 100644 (file)
@@ -7,7 +7,7 @@ require_once __DIR__ . '/Maintenance.php';
 class TidyUpBug37714 extends Maintenance {
        public function execute() {
                // Search for all log entries which are about changing the visability of other log entries.
-               $result = wfGetDB( DB_SLAVE )->select(
+               $result = $this->getDB( DB_SLAVE )->select(
                        'logging',
                        array( 'log_id', 'log_params' ),
                        array(
@@ -22,7 +22,7 @@ class TidyUpBug37714 extends Maintenance {
                foreach ( $result as $row ) {
                        $paramLines = explode( "\n", $row->log_params );
                        $ids = explode( ',', $paramLines[0] ); // Array dereferencing is PHP >= 5.4 :(
-                       $result = wfGetDB( DB_SLAVE )->select( // Work out what log entries were changed here.
+                       $result = $this->getDB( DB_SLAVE )->select( // Work out what log entries were changed here.
                                'logging',
                                'log_type',
                                array( 'log_id' => $ids ),
@@ -33,7 +33,7 @@ class TidyUpBug37714 extends Maintenance {
                                // If there's only one type, the target title can be set to include it.
                                $logTitle = SpecialPage::getTitleFor( 'Log', $result->current()->log_type )->getText();
                                $this->output( 'Set log_title to "' . $logTitle . '" for log entry ' . $row->log_id . ".\n" );
-                               wfGetDB( DB_MASTER )->update(
+                               $this->getDB( DB_MASTER )->update(
                                        'logging',
                                        array( 'log_title' => $logTitle ),
                                        array( 'log_id' => $row->log_id ),
index 452b53c..eeaf9c8 100755 (executable)
@@ -139,7 +139,7 @@ class UpdateMediaWiki extends Maintenance {
 
                # Attempt to connect to the database as a privileged user
                # This will vomit up an error if there are permissions problems
-               $db = wfGetDB( DB_MASTER );
+               $db = $this->getDB( DB_MASTER );
 
                $this->output( "Going to run database updates for " . wfWikiID() . "\n" );
                if ( $db->getType() === 'sqlite' ) {
index 55f535d..9537a79 100644 (file)
@@ -44,9 +44,9 @@ class UpdateArticleCount extends Maintenance {
                $this->output( "Counting articles..." );
 
                if ( $this->hasOption( 'use-master' ) ) {
-                       $dbr = wfGetDB( DB_MASTER );
+                       $dbr = $this->getDB( DB_MASTER );
                } else {
-                       $dbr = wfGetDB( DB_SLAVE, 'vslow' );
+                       $dbr = $this->getDB( DB_SLAVE, 'vslow' );
                }
                $counter = new SiteStatsInit( $dbr );
                $result = $counter->articles();
@@ -54,7 +54,7 @@ class UpdateArticleCount extends Maintenance {
                $this->output( "found {$result}.\n" );
                if ( $this->hasOption( 'update' ) ) {
                        $this->output( "Updating site statistics table... " );
-                       $dbw = wfGetDB( DB_MASTER );
+                       $dbw = $this->getDB( DB_MASTER );
                        $dbw->update(
                                'site_stats',
                                array( 'ss_good_articles' => $result ),
index 796cedd..5c21b40 100644 (file)
@@ -51,7 +51,7 @@ class UpdateDoubleWidthSearch extends Maintenance {
        public function execute() {
                $maxLockTime = $this->getOption( 'l', 20 );
 
-               $dbw = wfGetDB( DB_MASTER );
+               $dbw = $this->getDB( DB_MASTER );
                if ( $dbw->getType() !== 'mysql' ) {
                        $this->error( "This change is only needed on MySQL, quitting.\n", true );
                }
index 5b5cc04..ebfffe4 100644 (file)
@@ -40,7 +40,7 @@ class UpdateRestrictions extends Maintenance {
        }
 
        public function execute() {
-               $db = wfGetDB( DB_MASTER );
+               $db = $this->getDB( DB_MASTER );
                if ( !$db->tableExists( 'page_restrictions' ) ) {
                        $this->error( "page_restrictions table does not exist", true );
                }
index 68a51bd..18edecc 100644 (file)
@@ -96,7 +96,7 @@ class UpdateSearchIndex extends Maintenance {
 
                $wgDisableSearchUpdate = false;
 
-               $dbw = wfGetDB( DB_MASTER );
+               $dbw = $this->getDB( DB_MASTER );
                $recentchanges = $dbw->tableName( 'recentchanges' );
 
                $this->output( "Updating searchindex between $start and $end\n" );
index c800664..8b24b90 100644 (file)
@@ -42,7 +42,7 @@ class UpdateSpecialPages extends Maintenance {
        public function execute() {
                global $wgQueryCacheLimit, $wgDisableQueryPageUpdate;
 
-               $dbw = wfGetDB( DB_MASTER );
+               $dbw = $this->getDB( DB_MASTER );
 
                $this->doSpecialPageCacheUpdates( $dbw );