From 44cebea941236e165bf55e80565d6679529c7280 Mon Sep 17 00:00:00 2001 From: Reedy Date: Thu, 31 Dec 2015 00:07:37 +0000 Subject: [PATCH] Update wfGetDB calls in Maintenance scripts to use getDB() Change-Id: I9ad6745d84506b736dae94747256caac89715899 --- maintenance/archives/upgradeLogging.php | 2 +- maintenance/attachLatest.php | 2 +- maintenance/benchmarks/bench_delete_truncate.php | 2 +- maintenance/benchmarks/benchmarkParse.php | 2 +- maintenance/checkBadRedirects.php | 2 +- maintenance/checkImages.php | 2 +- maintenance/checkUsernames.php | 2 +- maintenance/cleanupAncientTables.php | 2 +- maintenance/cleanupBlocks.php | 2 +- maintenance/cleanupImages.php | 4 ++-- maintenance/cleanupRemovedModules.php | 2 +- maintenance/cleanupSpam.php | 6 +++--- maintenance/cleanupTable.inc | 2 +- maintenance/cleanupTitles.php | 6 +++--- maintenance/cleanupWatchlist.php | 2 +- maintenance/clearInterwikiCache.php | 2 +- maintenance/convertLinks.php | 4 ++-- maintenance/convertUserOptions.php | 2 +- maintenance/deleteBatch.php | 2 +- maintenance/deleteDefaultMessages.php | 4 ++-- maintenance/deleteEqualMessages.php | 2 +- maintenance/deleteOldRevisions.php | 2 +- maintenance/deleteOrphanedRevisions.php | 2 +- maintenance/deleteRevision.php | 2 +- maintenance/deleteSelfExternals.php | 2 +- maintenance/dumpLinks.php | 2 +- maintenance/dumpUploads.php | 4 ++-- maintenance/eraseArchivedFile.php | 4 ++-- maintenance/fetchText.php | 2 +- maintenance/fixDefaultJsonContentPages.php | 4 ++-- maintenance/fixDoubleRedirects.php | 2 +- maintenance/fixExtLinksProtocolRelative.php | 2 +- maintenance/fixTimestamps.php | 2 +- maintenance/fixUserRegistration.php | 2 +- maintenance/generateSitemap.php | 2 +- maintenance/getSlaveServer.php | 2 +- maintenance/getText.php | 2 -- maintenance/importDump.php | 2 +- maintenance/initEditCount.php | 4 ++-- maintenance/initSiteStats.php | 2 +- maintenance/migrateUserGroup.php | 2 +- maintenance/moveBatch.php | 2 +- maintenance/namespaceDupes.php | 2 +- maintenance/nukeNS.php | 2 +- maintenance/nukePage.php | 4 ++-- maintenance/oracle/alterSharedConstraints.php | 2 +- maintenance/orphans.php | 6 +++--- maintenance/patchSql.php | 2 +- maintenance/populateCategory.php | 2 +- maintenance/populateContentModel.php | 2 +- maintenance/populateFilearchiveSha1.php | 2 +- maintenance/populateImageSha1.php | 2 +- maintenance/populateParentId.php | 2 +- maintenance/purgeList.php | 2 +- maintenance/reassignEdits.php | 2 +- maintenance/rebuildFileCache.php | 4 ++-- maintenance/rebuildImages.php | 4 ++-- maintenance/rebuildall.php | 2 +- maintenance/rebuildrecentchanges.php | 8 ++++---- maintenance/rebuildtextindex.php | 3 +-- maintenance/refreshFileHeaders.php | 2 +- maintenance/refreshImageMetadata.php | 2 +- maintenance/refreshLinks.php | 10 +++++----- maintenance/removeUnusedAccounts.php | 6 +++--- maintenance/renameDbPrefix.php | 2 +- maintenance/resetUserTokens.php | 2 +- maintenance/rollbackEdits.php | 2 +- maintenance/runBatchedQuery.php | 2 +- maintenance/showSiteStats.php | 2 +- maintenance/sqlite.php | 2 +- maintenance/storage/compressOld.php | 8 ++++---- maintenance/storage/dumpRev.php | 2 +- maintenance/storage/fixBug20757.php | 6 +++--- maintenance/storage/orphanStats.php | 2 +- maintenance/storage/storageTypeStats.php | 2 +- maintenance/storage/testCompression.php | 2 +- maintenance/tidyUpBug37714.php | 6 +++--- maintenance/update.php | 2 +- maintenance/updateArticleCount.php | 6 +++--- maintenance/updateDoubleWidthSearch.php | 2 +- maintenance/updateRestrictions.php | 2 +- maintenance/updateSearchIndex.php | 2 +- maintenance/updateSpecialPages.php | 2 +- 83 files changed, 116 insertions(+), 119 deletions(-) diff --git a/maintenance/archives/upgradeLogging.php b/maintenance/archives/upgradeLogging.php index aeadc93d4d..d5b98b5f50 100644 --- a/maintenance/archives/upgradeLogging.php +++ b/maintenance/archives/upgradeLogging.php @@ -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' ); diff --git a/maintenance/attachLatest.php b/maintenance/attachLatest.php index fba6b92db2..a2ea554c18 100644 --- a/maintenance/attachLatest.php +++ b/maintenance/attachLatest.php @@ -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 = ''; diff --git a/maintenance/benchmarks/bench_delete_truncate.php b/maintenance/benchmarks/bench_delete_truncate.php index 8ae4f03094..572c5487ca 100644 --- a/maintenance/benchmarks/bench_delete_truncate.php +++ b/maintenance/benchmarks/bench_delete_truncate.php @@ -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 ( diff --git a/maintenance/benchmarks/benchmarkParse.php b/maintenance/benchmarks/benchmarkParse.php index ce38dad6a0..b850e638d0 100644 --- a/maintenance/benchmarks/benchmarkParse.php +++ b/maintenance/benchmarks/benchmarkParse.php @@ -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' ), diff --git a/maintenance/checkBadRedirects.php b/maintenance/checkBadRedirects.php index fec92910e4..500fc35439 100644 --- a/maintenance/checkBadRedirects.php +++ b/maintenance/checkBadRedirects.php @@ -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' ), diff --git a/maintenance/checkImages.php b/maintenance/checkImages.php index 0364db20e5..976192711f 100644 --- a/maintenance/checkImages.php +++ b/maintenance/checkImages.php @@ -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; diff --git a/maintenance/checkUsernames.php b/maintenance/checkUsernames.php index a64bc498fa..6f4d170457 100644 --- a/maintenance/checkUsernames.php +++ b/maintenance/checkUsernames.php @@ -40,7 +40,7 @@ class CheckUsernames extends Maintenance { } function execute() { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = $this->getDB( DB_SLAVE ); $maxUserId = 0; do { diff --git a/maintenance/cleanupAncientTables.php b/maintenance/cleanupAncientTables.php index 2dbf8bc1bb..f1467d5ffc 100644 --- a/maintenance/cleanupAncientTables.php +++ b/maintenance/cleanupAncientTables.php @@ -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 diff --git a/maintenance/cleanupBlocks.php b/maintenance/cleanupBlocks.php index 1736203b3a..437abe9597 100644 --- a/maintenance/cleanupBlocks.php +++ b/maintenance/cleanupBlocks.php @@ -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)' ); diff --git a/maintenance/cleanupImages.php b/maintenance/cleanupImages.php index 5baa8d3bc7..ab2d808606 100644 --- a/maintenance/cleanupImages.php +++ b/maintenance/cleanupImages.php @@ -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, diff --git a/maintenance/cleanupRemovedModules.php b/maintenance/cleanupRemovedModules.php index 68f57a39d7..810fad902e 100644 --- a/maintenance/cleanupRemovedModules.php +++ b/maintenance/cleanupRemovedModules.php @@ -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 ) ); diff --git a/maintenance/cleanupSpam.php b/maintenance/cleanupSpam.php index e6471dd1c4..b43ce814d6 100644 --- a/maintenance/cleanupSpam.php +++ b/maintenance/cleanupSpam.php @@ -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 ) { diff --git a/maintenance/cleanupTable.inc b/maintenance/cleanupTable.inc index 74073bc588..0ddaf3301b 100644 --- a/maintenance/cleanupTable.inc +++ b/maintenance/cleanupTable.inc @@ -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' ) ) diff --git a/maintenance/cleanupTitles.php b/maintenance/cleanupTitles.php index 1eba303a9e..07df1b1444 100644 --- a/maintenance/cleanupTitles.php +++ b/maintenance/cleanupTitles.php @@ -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, diff --git a/maintenance/cleanupWatchlist.php b/maintenance/cleanupWatchlist.php index eb7d7b1895..16f7b616de 100644 --- a/maintenance/cleanupWatchlist.php +++ b/maintenance/cleanupWatchlist.php @@ -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, diff --git a/maintenance/clearInterwikiCache.php b/maintenance/clearInterwikiCache.php index 80c9004e43..6a6527f527 100644 --- a/maintenance/clearInterwikiCache.php +++ b/maintenance/clearInterwikiCache.php @@ -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 ) { diff --git a/maintenance/convertLinks.php b/maintenance/convertLinks.php index c3ad46a012..15ca14b70a 100644 --- a/maintenance/convertLinks.php +++ b/maintenance/convertLinks.php @@ -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" ); diff --git a/maintenance/convertUserOptions.php b/maintenance/convertUserOptions.php index 1542a8c37e..11768c8a56 100644 --- a/maintenance/convertUserOptions.php +++ b/maintenance/convertUserOptions.php @@ -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. " ); diff --git a/maintenance/deleteBatch.php b/maintenance/deleteBatch.php index a3b1561a69..6c89e671ea 100644 --- a/maintenance/deleteBatch.php +++ b/maintenance/deleteBatch.php @@ -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 diff --git a/maintenance/deleteDefaultMessages.php b/maintenance/deleteDefaultMessages.php index a1c0f616b0..a5c6199534 100644 --- a/maintenance/deleteDefaultMessages.php +++ b/maintenance/deleteDefaultMessages.php @@ -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(); diff --git a/maintenance/deleteEqualMessages.php b/maintenance/deleteEqualMessages.php index de5c5e23a4..e7bb866cab 100644 --- a/maintenance/deleteEqualMessages.php +++ b/maintenance/deleteEqualMessages.php @@ -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(); diff --git a/maintenance/deleteOldRevisions.php b/maintenance/deleteOldRevisions.php index 0c06ec50e1..f411148651 100644 --- a/maintenance/deleteOldRevisions.php +++ b/maintenance/deleteOldRevisions.php @@ -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(); diff --git a/maintenance/deleteOrphanedRevisions.php b/maintenance/deleteOrphanedRevisions.php index 776d34543f..3d5c1a4d07 100644 --- a/maintenance/deleteOrphanedRevisions.php +++ b/maintenance/deleteOrphanedRevisions.php @@ -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' ); diff --git a/maintenance/deleteRevision.php b/maintenance/deleteRevision.php index 818ee360dd..6cda78483d 100644 --- a/maintenance/deleteRevision.php +++ b/maintenance/deleteRevision.php @@ -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 ) { diff --git a/maintenance/deleteSelfExternals.php b/maintenance/deleteSelfExternals.php index a3976634f3..f9bb41610f 100644 --- a/maintenance/deleteSelfExternals.php +++ b/maintenance/deleteSelfExternals.php @@ -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__ ); diff --git a/maintenance/dumpLinks.php b/maintenance/dumpLinks.php index 888c2dc1d9..74b500a1c4 100644 --- a/maintenance/dumpLinks.php +++ b/maintenance/dumpLinks.php @@ -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', diff --git a/maintenance/dumpUploads.php b/maintenance/dumpUploads.php index 9d53f07c1d..026ac025c0 100644 --- a/maintenance/dumpUploads.php +++ b/maintenance/dumpUploads.php @@ -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' ), '', diff --git a/maintenance/eraseArchivedFile.php b/maintenance/eraseArchivedFile.php index 8fdcef3ab4..69a95e20bd 100644 --- a/maintenance/eraseArchivedFile.php +++ b/maintenance/eraseArchivedFile.php @@ -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__ ); diff --git a/maintenance/fetchText.php b/maintenance/fetchText.php index 983b772515..cf128388db 100644 --- a/maintenance/fetchText.php +++ b/maintenance/fetchText.php @@ -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 ); diff --git a/maintenance/fixDefaultJsonContentPages.php b/maintenance/fixDefaultJsonContentPages.php index 12658910ec..25ec34252c 100644 --- a/maintenance/fixDefaultJsonContentPages.php +++ b/maintenance/fixDefaultJsonContentPages.php @@ -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 diff --git a/maintenance/fixDoubleRedirects.php b/maintenance/fixDoubleRedirects.php index 9568284708..ca551f87b4 100644 --- a/maintenance/fixDoubleRedirects.php +++ b/maintenance/fixDoubleRedirects.php @@ -54,7 +54,7 @@ class FixDoubleRedirects extends Maintenance { $title = null; } - $dbr = wfGetDB( DB_SLAVE ); + $dbr = $this->getDB( DB_SLAVE ); // See also SpecialDoubleRedirects $tables = array( diff --git a/maintenance/fixExtLinksProtocolRelative.php b/maintenance/fixExtLinksProtocolRelative.php index 0c60e62c70..a44f8e5087 100644 --- a/maintenance/fixExtLinksProtocolRelative.php +++ b/maintenance/fixExtLinksProtocolRelative.php @@ -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" ); diff --git a/maintenance/fixTimestamps.php b/maintenance/fixTimestamps.php index 5431cf2cd1..c2a748c4d0 100644 --- a/maintenance/fixTimestamps.php +++ b/maintenance/fixTimestamps.php @@ -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__ ); diff --git a/maintenance/fixUserRegistration.php b/maintenance/fixUserRegistration.php index 40e091595e..d09760b4bd 100644 --- a/maintenance/fixUserRegistration.php +++ b/maintenance/fixUserRegistration.php @@ -37,7 +37,7 @@ class FixUserRegistration extends Maintenance { } public function execute() { - $dbw = wfGetDB( DB_MASTER ); + $dbw = $this->getDB( DB_MASTER ); $lastId = 0; do { diff --git a/maintenance/generateSitemap.php b/maintenance/generateSitemap.php index 12711ea3ff..c40d0ce706 100644 --- a/maintenance/generateSitemap.php +++ b/maintenance/generateSitemap.php @@ -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' ); diff --git a/maintenance/getSlaveServer.php b/maintenance/getSlaveServer.php index 68c19439ad..c858c38673 100644 --- a/maintenance/getSlaveServer.php +++ b/maintenance/getSlaveServer.php @@ -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(); diff --git a/maintenance/getText.php b/maintenance/getText.php index 7d7c1cc480..c4b8cc9bff 100644 --- a/maintenance/getText.php +++ b/maintenance/getText.php @@ -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 ) { diff --git a/maintenance/importDump.php b/maintenance/importDump.php index 43e5060a84..5806ffc936 100644 --- a/maintenance/importDump.php +++ b/maintenance/importDump.php @@ -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' ) ); } diff --git a/maintenance/initEditCount.php b/maintenance/initEditCount.php index 7c6e7d4fdd..dee5db8aef 100644 --- a/maintenance/initEditCount.php +++ b/maintenance/initEditCount.php @@ -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__ ); diff --git a/maintenance/initSiteStats.php b/maintenance/initSiteStats.php index cac33ecc49..8d26063c3a 100644 --- a/maintenance/initSiteStats.php +++ b/maintenance/initSiteStats.php @@ -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" ); } diff --git a/maintenance/migrateUserGroup.php b/maintenance/migrateUserGroup.php index a0c41fdc08..dc20eee2f6 100644 --- a/maintenance/migrateUserGroup.php +++ b/maintenance/migrateUserGroup.php @@ -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)', diff --git a/maintenance/moveBatch.php b/maintenance/moveBatch.php index 8a81fdd528..43d4d25d15 100644 --- a/maintenance/moveBatch.php +++ b/maintenance/moveBatch.php @@ -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 diff --git a/maintenance/namespaceDupes.php b/maintenance/namespaceDupes.php index f67005dc47..6e5cd38ac5 100644 --- a/maintenance/namespaceDupes.php +++ b/maintenance/namespaceDupes.php @@ -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' ), diff --git a/maintenance/nukeNS.php b/maintenance/nukeNS.php index 04e2673761..0f2dbf64ff 100644 --- a/maintenance/nukeNS.php +++ b/maintenance/nukeNS.php @@ -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' ); diff --git a/maintenance/nukePage.php b/maintenance/nukePage.php index 94e340906e..dc45520996 100644 --- a/maintenance/nukePage.php +++ b/maintenance/nukePage.php @@ -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' ); diff --git a/maintenance/oracle/alterSharedConstraints.php b/maintenance/oracle/alterSharedConstraints.php index eea6f7b1fd..67e5ded8c6 100644 --- a/maintenance/oracle/alterSharedConstraints.php +++ b/maintenance/oracle/alterSharedConstraints.php @@ -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 ) { diff --git a/maintenance/orphans.php b/maintenance/orphans.php index 7e27107a44..3c5566f615 100644 --- a/maintenance/orphans.php +++ b/maintenance/orphans.php @@ -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' ); diff --git a/maintenance/patchSql.php b/maintenance/patchSql.php index 5d9fc1b41a..1f77bdb30c 100644 --- a/maintenance/patchSql.php +++ b/maintenance/patchSql.php @@ -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, diff --git a/maintenance/populateCategory.php b/maintenance/populateCategory.php index 65d272b303..481e07363b 100644 --- a/maintenance/populateCategory.php +++ b/maintenance/populateCategory.php @@ -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( diff --git a/maintenance/populateContentModel.php b/maintenance/populateContentModel.php index 7bca0ecb81..4f9c7ae377 100644 --- a/maintenance/populateContentModel.php +++ b/maintenance/populateContentModel.php @@ -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 ); diff --git a/maintenance/populateFilearchiveSha1.php b/maintenance/populateFilearchiveSha1.php index a3099f9615..5a67262b68 100644 --- a/maintenance/populateFilearchiveSha1.php +++ b/maintenance/populateFilearchiveSha1.php @@ -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' ); diff --git a/maintenance/populateImageSha1.php b/maintenance/populateImageSha1.php index e9123aa344..cc52239f31 100644 --- a/maintenance/populateImageSha1.php +++ b/maintenance/populateImageSha1.php @@ -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', diff --git a/maintenance/populateParentId.php b/maintenance/populateParentId.php index 686d9f2b7f..9baf28e6d1 100644 --- a/maintenance/populateParentId.php +++ b/maintenance/populateParentId.php @@ -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" ); diff --git a/maintenance/purgeList.php b/maintenance/purgeList.php index 31ea5d0899..9963cbf64d 100644 --- a/maintenance/purgeList.php +++ b/maintenance/purgeList.php @@ -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(); diff --git a/maintenance/reassignEdits.php b/maintenance/reassignEdits.php index 4d1c537cac..e68937acbe 100644 --- a/maintenance/reassignEdits.php +++ b/maintenance/reassignEdits.php @@ -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 diff --git a/maintenance/rebuildFileCache.php b/maintenance/rebuildFileCache.php index 4147491e61..e07bf03865 100644 --- a/maintenance/rebuildFileCache.php +++ b/maintenance/rebuildFileCache.php @@ -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 diff --git a/maintenance/rebuildImages.php b/maintenance/rebuildImages.php index b1bb353b08..1b0a27df66 100644 --- a/maintenance/rebuildImages.php +++ b/maintenance/rebuildImages.php @@ -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 ); diff --git a/maintenance/rebuildall.php b/maintenance/rebuildall.php index eeee9c21b7..4ff873e9c6 100644 --- a/maintenance/rebuildall.php +++ b/maintenance/rebuildall.php @@ -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' ); diff --git a/maintenance/rebuildrecentchanges.php b/maintenance/rebuildrecentchanges.php index cdaa777a61..b6421f347b 100644 --- a/maintenance/rebuildrecentchanges.php +++ b/maintenance/rebuildrecentchanges.php @@ -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' ); diff --git a/maintenance/rebuildtextindex.php b/maintenance/rebuildtextindex.php index e29d89e193..e8d59bc4bc 100644 --- a/maintenance/rebuildtextindex.php +++ b/maintenance/rebuildtextindex.php @@ -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 " diff --git a/maintenance/refreshFileHeaders.php b/maintenance/refreshFileHeaders.php index 8b852e3947..6bc72ec838 100644 --- a/maintenance/refreshFileHeaders.php +++ b/maintenance/refreshFileHeaders.php @@ -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 ) ) { diff --git a/maintenance/refreshImageMetadata.php b/maintenance/refreshImageMetadata.php index 831118ca7b..4f2341ce01 100644 --- a/maintenance/refreshImageMetadata.php +++ b/maintenance/refreshImageMetadata.php @@ -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 ); } diff --git a/maintenance/refreshLinks.php b/maintenance/refreshLinks.php index ed168053d5..a0cd6a94f1 100644 --- a/maintenance/refreshLinks.php +++ b/maintenance/refreshLinks.php @@ -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', diff --git a/maintenance/removeUnusedAccounts.php b/maintenance/removeUnusedAccounts.php index 6416407a99..7937dd0e9c 100644 --- a/maintenance/removeUnusedAccounts.php +++ b/maintenance/removeUnusedAccounts.php @@ -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', diff --git a/maintenance/renameDbPrefix.php b/maintenance/renameDbPrefix.php index ed9d1f5d62..2772f04b19 100644 --- a/maintenance/renameDbPrefix.php +++ b/maintenance/renameDbPrefix.php @@ -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" diff --git a/maintenance/resetUserTokens.php b/maintenance/resetUserTokens.php index 08be553773..9c7aef29db 100644 --- a/maintenance/resetUserTokens.php +++ b/maintenance/resetUserTokens.php @@ -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 ) { diff --git a/maintenance/rollbackEdits.php b/maintenance/rollbackEdits.php index 7be5a1f990..7134453570 100644 --- a/maintenance/rollbackEdits.php +++ b/maintenance/rollbackEdits.php @@ -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' ), diff --git a/maintenance/runBatchedQuery.php b/maintenance/runBatchedQuery.php index af8890509e..3fd9e02bac 100644 --- a/maintenance/runBatchedQuery.php +++ b/maintenance/runBatchedQuery.php @@ -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++; diff --git a/maintenance/showSiteStats.php b/maintenance/showSiteStats.php index 370d14eba0..56cc5737b8 100644 --- a/maintenance/showSiteStats.php +++ b/maintenance/showSiteStats.php @@ -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 diff --git a/maintenance/sqlite.php b/maintenance/sqlite.php index b11f1c8ba6..96a8a380a8 100644 --- a/maintenance/sqlite.php +++ b/maintenance/sqlite.php @@ -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" ); diff --git a/maintenance/storage/compressOld.php b/maintenance/storage/compressOld.php index f115bf8fc5..b27b111e18 100644 --- a/maintenance/storage/compressOld.php +++ b/maintenance/storage/compressOld.php @@ -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 != '' ) { diff --git a/maintenance/storage/dumpRev.php b/maintenance/storage/dumpRev.php index f12bbd1b73..dcb76e313c 100644 --- a/maintenance/storage/dumpRev.php +++ b/maintenance/storage/dumpRev.php @@ -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' ), diff --git a/maintenance/storage/fixBug20757.php b/maintenance/storage/fixBug20757.php index c6692b5945..e926f56bae 100644 --- a/maintenance/storage/fixBug20757.php +++ b/maintenance/storage/fixBug20757.php @@ -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' ), diff --git a/maintenance/storage/orphanStats.php b/maintenance/storage/orphanStats.php index c5213ad17f..b1bf95b42b 100644 --- a/maintenance/storage/orphanStats.php +++ b/maintenance/storage/orphanStats.php @@ -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 ); } diff --git a/maintenance/storage/storageTypeStats.php b/maintenance/storage/storageTypeStats.php index e33057f612..e156efe347 100644 --- a/maintenance/storage/storageTypeStats.php +++ b/maintenance/storage/storageTypeStats.php @@ -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 ) { diff --git a/maintenance/storage/testCompression.php b/maintenance/storage/testCompression.php index f7ec6624e6..148a9d1834 100644 --- a/maintenance/storage/testCompression.php +++ b/maintenance/storage/testCompression.php @@ -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' ), '*', diff --git a/maintenance/tidyUpBug37714.php b/maintenance/tidyUpBug37714.php index 1ad9c7ee25..eac7b3f91e 100644 --- a/maintenance/tidyUpBug37714.php +++ b/maintenance/tidyUpBug37714.php @@ -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 ), diff --git a/maintenance/update.php b/maintenance/update.php index 452b53cd7d..eeaf9c83b0 100755 --- a/maintenance/update.php +++ b/maintenance/update.php @@ -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' ) { diff --git a/maintenance/updateArticleCount.php b/maintenance/updateArticleCount.php index 55f535d20e..9537a79515 100644 --- a/maintenance/updateArticleCount.php +++ b/maintenance/updateArticleCount.php @@ -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 ), diff --git a/maintenance/updateDoubleWidthSearch.php b/maintenance/updateDoubleWidthSearch.php index 796cedd98d..5c21b40eb4 100644 --- a/maintenance/updateDoubleWidthSearch.php +++ b/maintenance/updateDoubleWidthSearch.php @@ -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 ); } diff --git a/maintenance/updateRestrictions.php b/maintenance/updateRestrictions.php index 5b5cc04895..ebfffe4d8a 100644 --- a/maintenance/updateRestrictions.php +++ b/maintenance/updateRestrictions.php @@ -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 ); } diff --git a/maintenance/updateSearchIndex.php b/maintenance/updateSearchIndex.php index 68a51bd9a5..18edecceae 100644 --- a/maintenance/updateSearchIndex.php +++ b/maintenance/updateSearchIndex.php @@ -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" ); diff --git a/maintenance/updateSpecialPages.php b/maintenance/updateSpecialPages.php index c800664cc1..8b24b90cb8 100644 --- a/maintenance/updateSpecialPages.php +++ b/maintenance/updateSpecialPages.php @@ -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 ); -- 2.20.1