From 950cf6016c10953213e5f985dfc18a32d8673197 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Mon, 5 Sep 2016 12:55:19 -0700 Subject: [PATCH] Rename DB_SLAVE constant to DB_REPLICA This is more consistent with LoadBalancer, modern, and inclusive of master/master mysql, NDB cluster, and MariaDB galera cluster. The old constant is an alias now. Change-Id: I0b37299ecb439cc446ffbe8c341365d1eef45849 --- includes/Block.php | 16 +++---- includes/Category.php | 4 +- includes/CategoryFinder.php | 2 +- includes/CategoryViewer.php | 2 +- includes/DefaultSettings.php | 2 +- includes/Defines.php | 3 +- includes/EditPage.php | 2 +- includes/GlobalFunctions.php | 6 +-- includes/HistoryBlob.php | 4 +- includes/LinkFilter.php | 2 +- includes/Linker.php | 2 +- includes/OutputPage.php | 2 +- includes/PageProps.php | 4 +- includes/Pingback.php | 4 +- includes/PrefixSearch.php | 2 +- includes/Revision.php | 18 +++---- includes/RevisionList.php | 2 +- includes/SiteStats.php | 12 ++--- includes/Title.php | 48 +++++++++---------- includes/WatchedItemQueryService.php | 2 +- includes/WatchedItemStore.php | 20 ++++---- includes/actions/HistoryAction.php | 2 +- includes/actions/InfoAction.php | 4 +- includes/api/ApiBase.php | 2 +- includes/api/ApiQueryUserContributions.php | 2 +- includes/api/ApiQueryWatchlist.php | 2 +- includes/api/ApiStashEdit.php | 2 +- includes/api/ApiTag.php | 2 +- ...yPasswordPrimaryAuthenticationProvider.php | 4 +- includes/cache/BacklinkCache.php | 2 +- includes/cache/GenderCache.php | 2 +- includes/cache/LinkBatch.php | 2 +- includes/cache/LinkCache.php | 2 +- includes/cache/MessageBlobStore.php | 2 +- includes/cache/MessageCache.php | 2 +- includes/cache/UserCache.php | 2 +- includes/cache/localisation/LCStoreDB.php | 2 +- includes/changes/RecentChange.php | 2 +- includes/changetags/ChangeTags.php | 10 ++-- includes/content/ContentHandler.php | 2 +- includes/dao/DBAccessObjectUtils.php | 4 +- includes/db/loadbalancer/LoadBalancer.php | 8 ++-- includes/deferred/SiteStatsUpdate.php | 2 +- includes/diff/DifferenceEngine.php | 6 +-- includes/externalstore/ExternalStoreDB.php | 2 +- .../filerepo/FileBackendDBRepoWrapper.php | 2 +- includes/filerepo/ForeignDBViaLBRepo.php | 2 +- includes/filerepo/LocalRepo.php | 4 +- includes/filerepo/file/ArchivedFile.php | 2 +- includes/interwiki/ClassicInterwikiLookup.php | 4 +- includes/jobqueue/JobQueueDB.php | 4 +- .../jobs/CategoryMembershipChangeJob.php | 2 +- includes/libs/objectcache/WANObjectCache.php | 10 ++-- includes/logging/LogPager.php | 2 +- includes/objectcache/SqlBagOStuff.php | 2 +- includes/page/Article.php | 4 +- includes/page/ImagePage.php | 2 +- includes/page/WikiPage.php | 18 +++---- includes/pager/IndexPager.php | 2 +- includes/parser/LinkHolderArray.php | 4 +- includes/parser/Parser.php | 4 +- includes/resourceloader/ResourceLoader.php | 4 +- .../resourceloader/ResourceLoaderModule.php | 2 +- .../ResourceLoaderWikiModule.php | 2 +- includes/revisiondelete/RevDelLogList.php | 2 +- includes/revisiondelete/RevisionDeleter.php | 2 +- includes/search/SearchDatabase.php | 2 +- includes/search/SearchEngineFactory.php | 2 +- includes/search/SearchMySQL.php | 2 +- includes/site/DBSiteStore.php | 2 +- .../specialpage/ChangesListSpecialPage.php | 2 +- includes/specialpage/QueryPage.php | 6 +-- includes/specials/SpecialActiveusers.php | 2 +- includes/specials/SpecialAllPages.php | 2 +- includes/specials/SpecialBlockList.php | 2 +- includes/specials/SpecialBotPasswords.php | 2 +- includes/specials/SpecialBrokenRedirects.php | 2 +- includes/specials/SpecialDoubleRedirects.php | 4 +- includes/specials/SpecialExport.php | 10 ++-- includes/specials/SpecialLinkSearch.php | 4 +- includes/specials/SpecialMediaStatistics.php | 2 +- includes/specials/SpecialMovepage.php | 2 +- includes/specials/SpecialPagesWithProp.php | 2 +- includes/specials/SpecialPrefixindex.php | 2 +- includes/specials/SpecialRandomInCategory.php | 6 +-- includes/specials/SpecialRandompage.php | 2 +- includes/specials/SpecialRandomrootpage.php | 2 +- includes/specials/SpecialRecentchanges.php | 2 +- .../specials/SpecialRecentchangeslinked.php | 2 +- includes/specials/SpecialRedirect.php | 2 +- includes/specials/SpecialUndelete.php | 20 ++++---- includes/specials/SpecialVersion.php | 2 +- includes/specials/SpecialWatchlist.php | 2 +- includes/specials/SpecialWhatlinkshere.php | 2 +- includes/specials/SpecialWithoutinterwiki.php | 2 +- .../specials/pagers/AllMessagesTablePager.php | 2 +- includes/specials/pagers/ContribsPager.php | 2 +- .../specials/pagers/DeletedContribsPager.php | 2 +- includes/specials/pagers/ImageListPager.php | 6 +-- .../specials/pagers/MergeHistoryPager.php | 2 +- includes/specials/pagers/NewFilesPager.php | 2 +- includes/specials/pagers/UsersPager.php | 4 +- includes/upload/UploadStash.php | 4 +- includes/user/BotPassword.php | 2 +- includes/user/LocalIdLookup.php | 4 +- includes/user/PasswordReset.php | 2 +- includes/user/User.php | 30 ++++++------ includes/user/UserArray.php | 4 +- includes/user/UserNamePrefixSearch.php | 2 +- maintenance/Maintenance.php | 2 +- maintenance/backup.inc | 4 +- maintenance/benchmarks/benchmarkParse.php | 2 +- maintenance/checkBadRedirects.php | 2 +- maintenance/checkImages.php | 2 +- maintenance/checkUsernames.php | 2 +- maintenance/cleanupSpam.php | 4 +- maintenance/cleanupTable.inc | 2 +- maintenance/cleanupTitles.php | 2 +- maintenance/clearInterwikiCache.php | 2 +- maintenance/compareParserCache.php | 2 +- maintenance/deleteDefaultMessages.php | 2 +- maintenance/dumpLinks.php | 2 +- maintenance/dumpTextPass.php | 2 +- maintenance/dumpUploads.php | 4 +- maintenance/fetchText.php | 2 +- maintenance/fixDefaultJsonContentPages.php | 2 +- maintenance/fixDoubleRedirects.php | 2 +- maintenance/generateSitemap.php | 2 +- maintenance/getReplicaServer.php | 2 +- maintenance/initEditCount.php | 2 +- maintenance/populateRevisionLength.php | 2 +- maintenance/purgeChangedFiles.php | 4 +- maintenance/purgeChangedPages.php | 2 +- maintenance/purgeList.php | 2 +- maintenance/rebuildFileCache.php | 2 +- maintenance/rebuildImages.php | 2 +- maintenance/rebuildall.php | 2 +- maintenance/refreshFileHeaders.php | 2 +- maintenance/refreshLinks.php | 6 +-- maintenance/removeInvalidEmails.php | 2 +- maintenance/removeUnusedAccounts.php | 4 +- maintenance/resetUserTokens.php | 3 +- maintenance/rollbackEdits.php | 2 +- maintenance/showSiteStats.php | 2 +- maintenance/sql.php | 2 +- maintenance/storage/checkStorage.php | 6 +-- maintenance/storage/compressOld.php | 2 +- maintenance/storage/dumpRev.php | 2 +- maintenance/storage/fixBug20757.php | 4 +- maintenance/storage/moveToExternal.php | 2 +- maintenance/storage/orphanStats.php | 4 +- maintenance/storage/recompressTracked.php | 14 +++--- maintenance/storage/resolveStubs.php | 4 +- maintenance/storage/storageTypeStats.php | 2 +- maintenance/storage/testCompression.php | 2 +- maintenance/storage/trackBlobs.php | 10 ++-- maintenance/tidyUpBug37714.php | 4 +- maintenance/updateArticleCount.php | 2 +- maintenance/updateCollation.php | 2 +- maintenance/userOptions.inc | 4 +- 160 files changed, 314 insertions(+), 312 deletions(-) diff --git a/includes/Block.php b/includes/Block.php index 99db22e7e2..19ba0a28fb 100644 --- a/includes/Block.php +++ b/includes/Block.php @@ -145,7 +145,7 @@ class Block { $this->mReason = $options['reason']; $this->mTimestamp = wfTimestamp( TS_MW, $options['timestamp'] ); - $this->mExpiry = wfGetDB( DB_SLAVE )->decodeExpiry( $options['expiry'] ); + $this->mExpiry = wfGetDB( DB_REPLICA )->decodeExpiry( $options['expiry'] ); # Boolean settings $this->mAuto = (bool)$options['auto']; @@ -168,7 +168,7 @@ class Block { * @return Block|null */ public static function newFromID( $id ) { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $res = $dbr->selectRow( 'ipblocks', self::selectFields(), @@ -242,7 +242,7 @@ class Block { * @return bool Whether a relevant block was found */ protected function newLoad( $vagueTarget = null ) { - $db = wfGetDB( $this->mFromMaster ? DB_MASTER : DB_SLAVE ); + $db = wfGetDB( $this->mFromMaster ? DB_MASTER : DB_REPLICA ); if ( $this->type !== null ) { $conds = [ @@ -351,7 +351,7 @@ class Block { # range. We know that all blocks must be smaller than $wgBlockCIDRLimit, # so we can improve performance by filtering on a LIKE clause $chunk = self::getIpFragment( $start ); - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $like = $dbr->buildLike( $chunk, $dbr->anyString() ); # Fairly hard to make a malicious SQL statement out of hex characters, @@ -405,7 +405,7 @@ class Block { $this->mParentBlockId = $row->ipb_parent_block_id; // I wish I didn't have to do this - $this->mExpiry = wfGetDB( DB_SLAVE )->decodeExpiry( $row->ipb_expiry ); + $this->mExpiry = wfGetDB( DB_REPLICA )->decodeExpiry( $row->ipb_expiry ); $this->isHardblock( !$row->ipb_anon_only ); $this->isAutoblocking( $row->ipb_enable_autoblock ); @@ -569,7 +569,7 @@ class Block { */ protected function getDatabaseArray( $db = null ) { if ( !$db ) { - $db = wfGetDB( DB_SLAVE ); + $db = wfGetDB( DB_REPLICA ); } $expiry = $db->encodeExpiry( $this->mExpiry ); @@ -653,7 +653,7 @@ class Block { return; } - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $options = [ 'ORDER BY' => 'rc_timestamp DESC' ]; $conds = [ 'rc_user_text' => (string)$block->getTarget() ]; @@ -1146,7 +1146,7 @@ class Block { if ( $fromMaster ) { $db = wfGetDB( DB_MASTER ); } else { - $db = wfGetDB( DB_SLAVE ); + $db = wfGetDB( DB_REPLICA ); } $conds = $db->makeList( $conds, LIST_OR ); if ( !$isAnon ) { diff --git a/includes/Category.php b/includes/Category.php index 531e0be998..1ebd605c35 100644 --- a/includes/Category.php +++ b/includes/Category.php @@ -60,7 +60,7 @@ class Category { return true; } - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $row = $dbr->selectRow( 'category', [ 'cat_id', 'cat_title', 'cat_pages', 'cat_subcats', 'cat_files' ], @@ -264,7 +264,7 @@ class Category { */ public function getMembers( $limit = false, $offset = '' ) { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $conds = [ 'cl_to' => $this->getName(), 'cl_from = page_id' ]; $options = [ 'ORDER BY' => 'cl_sortkey' ]; diff --git a/includes/CategoryFinder.php b/includes/CategoryFinder.php index b6c63c70af..4efa2ff84c 100644 --- a/includes/CategoryFinder.php +++ b/includes/CategoryFinder.php @@ -96,7 +96,7 @@ class CategoryFinder { * @return array Array of page_ids (those given to seed() that match the conditions) */ public function run() { - $this->dbr = wfGetDB( DB_SLAVE ); + $this->dbr = wfGetDB( DB_REPLICA ); while ( count( $this->next ) > 0 ) { $this->scanNextLayer(); } diff --git a/includes/CategoryViewer.php b/includes/CategoryViewer.php index 490f548135..a8e988f614 100644 --- a/includes/CategoryViewer.php +++ b/includes/CategoryViewer.php @@ -286,7 +286,7 @@ class CategoryViewer extends ContextSource { } function doCategoryQuery() { - $dbr = wfGetDB( DB_SLAVE, 'category' ); + $dbr = wfGetDB( DB_REPLICA, 'category' ); $this->nextPage = [ 'page' => null, diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 1ffc3bdf72..0189416852 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -1895,7 +1895,7 @@ $wgSharedSchema = false; * - password: DB password * - type: DB type * - * - load: Ratio of DB_SLAVE load, must be >=0, the sum of all loads must be >0. + * - load: Ratio of DB_REPLICA load, must be >=0, the sum of all loads must be >0. * If this is zero for any given server, no normal query traffic will be * sent to it. It will be excluded from lag checks in maintenance scripts. * The only way it can receive traffic is if groupLoads is used. diff --git a/includes/Defines.php b/includes/Defines.php index f145483b6f..d0105abc96 100644 --- a/includes/Defines.php +++ b/includes/Defines.php @@ -43,11 +43,12 @@ define( 'DBO_COMPRESS', 512 ); * Valid database indexes * Operation-based indexes */ -define( 'DB_SLAVE', -1 ); # Read from the replica DB (or only server) +define( 'DB_REPLICA', -1 ); # Read from a replica (or only server) define( 'DB_MASTER', -2 ); # Write to master (or only server) /**@}*/ # Obsolete aliases +define( 'DB_SLAVE', -1 ); define( 'DB_READ', -1 ); define( 'DB_WRITE', -2 ); diff --git a/includes/EditPage.php b/includes/EditPage.php index e0080faf56..b98c908b78 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -3613,7 +3613,7 @@ HTML * @return bool|stdClass */ protected function getLastDelete() { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $data = $dbr->selectRow( [ 'logging', 'user' ], [ diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index aa6766baea..bc78be5d26 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -1278,7 +1278,7 @@ function wfReadOnly() { * Check if the site is in read-only mode and return the message if so * * This checks wfConfiguredReadOnlyReason() and the main load balancer - * for replica DB lag. This may result in DB_SLAVE connection being made. + * for replica DB lag. This may result in DB connection being made. * * @return string|bool String when in read-only mode; false otherwise */ @@ -3125,7 +3125,7 @@ function wfSplitWikiID( $wiki ) { * Get a Database object. * * @param int $db Index of the connection to get. May be DB_MASTER for the - * master (for write queries), DB_SLAVE for potentially lagged read + * master (for write queries), DB_REPLICA for potentially lagged read * queries, or an integer >= 0 for a particular server. * * @param string|string[] $groups Query groups. An array of group names that this query @@ -3134,7 +3134,7 @@ function wfSplitWikiID( $wiki ) { * * @param string|bool $wiki The wiki ID, or false for the current wiki * - * Note: multiple calls to wfGetDB(DB_SLAVE) during the course of one request + * Note: multiple calls to wfGetDB(DB_REPLICA) during the course of one request * will always return the same object, unless the underlying connection or load * balancer is manually destroyed. * diff --git a/includes/HistoryBlob.php b/includes/HistoryBlob.php index 8673125550..b17a2f5e2a 100644 --- a/includes/HistoryBlob.php +++ b/includes/HistoryBlob.php @@ -245,7 +245,7 @@ class HistoryBlobStub { if ( isset( self::$blobCache[$this->mOldId] ) ) { $obj = self::$blobCache[$this->mOldId]; } else { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $row = $dbr->selectRow( 'text', [ 'old_flags', 'old_text' ], @@ -336,7 +336,7 @@ class HistoryBlobCurStub { * @return string|bool */ function getText() { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $row = $dbr->selectRow( 'cur', [ 'cur_text' ], [ 'cur_id' => $this->mCurId ] ); if ( !$row ) { return false; diff --git a/includes/LinkFilter.php b/includes/LinkFilter.php index 802bfbe948..d86291a796 100644 --- a/includes/LinkFilter.php +++ b/includes/LinkFilter.php @@ -92,7 +92,7 @@ class LinkFilter { * @return array Array to be passed to Database::buildLike() or false on error */ public static function makeLikeArray( $filterEntry, $protocol = 'http://' ) { - $db = wfGetDB( DB_SLAVE ); + $db = wfGetDB( DB_REPLICA ); $target = $protocol . $filterEntry; $bits = wfParseUrl( $target ); diff --git a/includes/Linker.php b/includes/Linker.php index f8b1baef13..bcc348e7d6 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -1804,7 +1804,7 @@ class Linker { return null; } - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); // Up to the value of $wgShowRollbackEditCount revisions are counted $res = $dbr->select( diff --git a/includes/OutputPage.php b/includes/OutputPage.php index f3b3f8890e..6ae2a925f2 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -1265,7 +1265,7 @@ class OutputPage extends ContextSource { $lb->setArray( $arr ); # Fetch existence plus the hiddencat property - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $fields = array_merge( LinkCache::getSelectFields(), [ 'page_namespace', 'page_title', 'pp_value' ] diff --git a/includes/PageProps.php b/includes/PageProps.php index 5579ba5271..ed06935c2c 100644 --- a/includes/PageProps.php +++ b/includes/PageProps.php @@ -140,7 +140,7 @@ class PageProps { } if ( $queryIDs ) { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $result = $dbr->select( 'page_props', [ @@ -198,7 +198,7 @@ class PageProps { } if ( $queryIDs != [] ) { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $result = $dbr->select( 'page_props', [ diff --git a/includes/Pingback.php b/includes/Pingback.php index 0039d2b68c..bd1b2a25b4 100644 --- a/includes/Pingback.php +++ b/includes/Pingback.php @@ -72,7 +72,7 @@ class Pingback { * @return bool */ private function checkIfSent() { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $sent = $dbr->selectField( 'updatelog', '1', [ 'ul_key' => $this->key ], __METHOD__ ); return $sent !== false; @@ -168,7 +168,7 @@ class Pingback { */ private function getOrCreatePingbackId() { if ( !$this->id ) { - $id = wfGetDB( DB_SLAVE )->selectField( + $id = wfGetDB( DB_REPLICA )->selectField( 'updatelog', 'ul_value', [ 'ul_key' => 'PingBack' ] ); if ( $id == false ) { diff --git a/includes/PrefixSearch.php b/includes/PrefixSearch.php index 04c68ca8b2..49e596dff6 100644 --- a/includes/PrefixSearch.php +++ b/includes/PrefixSearch.php @@ -272,7 +272,7 @@ abstract class PrefixSearch { $t = Title::newFromText( $search, $ns ); $prefix = $t ? $t->getDBkey() : ''; - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $res = $dbr->select( 'page', [ 'page_id', 'page_namespace', 'page_title' ], [ diff --git a/includes/Revision.php b/includes/Revision.php index 39fd1d1bcf..03c3e6d99f 100644 --- a/includes/Revision.php +++ b/includes/Revision.php @@ -134,7 +134,7 @@ class Revision implements IDBAccessObject { } else { // Use a join to get the latest revision $conds[] = 'rev_id=page_latest'; - $db = wfGetDB( ( $flags & self::READ_LATEST ) ? DB_MASTER : DB_SLAVE ); + $db = wfGetDB( ( $flags & self::READ_LATEST ) ? DB_MASTER : DB_REPLICA ); return self::loadFromConds( $db, $conds, $flags ); } } @@ -161,7 +161,7 @@ class Revision implements IDBAccessObject { } else { // Use a join to get the latest revision $conds[] = 'rev_id = page_latest'; - $db = wfGetDB( ( $flags & self::READ_LATEST ) ? DB_MASTER : DB_SLAVE ); + $db = wfGetDB( ( $flags & self::READ_LATEST ) ? DB_MASTER : DB_REPLICA ); return self::loadFromConds( $db, $conds, $flags ); } } @@ -316,7 +316,7 @@ class Revision implements IDBAccessObject { * @return Revision|null */ private static function newFromConds( $conditions, $flags = 0 ) { - $db = wfGetDB( ( $flags & self::READ_LATEST ) ? DB_MASTER : DB_SLAVE ); + $db = wfGetDB( ( $flags & self::READ_LATEST ) ? DB_MASTER : DB_REPLICA ); $rev = self::loadFromConds( $db, $conditions, $flags ); // Make sure new pending/committed revision are visibile later on @@ -370,7 +370,7 @@ class Revision implements IDBAccessObject { */ public static function fetchRevision( LinkTarget $title ) { $row = self::fetchFromConds( - wfGetDB( DB_SLAVE ), + wfGetDB( DB_REPLICA ), [ 'rev_id=page_latest', 'page_namespace' => $title->getNamespace(), @@ -803,7 +803,7 @@ class Revision implements IDBAccessObject { } // rev_id is defined as NOT NULL, but this revision may not yet have been inserted. if ( $this->mId !== null ) { - $dbr = wfGetLB( $this->mWiki )->getConnectionRef( DB_SLAVE, [], $this->mWiki ); + $dbr = wfGetLB( $this->mWiki )->getConnectionRef( DB_REPLICA, [], $this->mWiki ); $row = $dbr->selectRow( [ 'page', 'revision' ], self::selectPageFields(), @@ -989,7 +989,7 @@ class Revision implements IDBAccessObject { * @return RecentChange|null */ public function getRecentChange( $flags = 0 ) { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); list( $dbType, ) = DBAccessObjectUtils::getDBOptions( $flags ); @@ -1610,7 +1610,7 @@ class Revision implements IDBAccessObject { if ( !$row ) { // Text data is immutable; check replica DBs first. - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $row = $dbr->selectRow( 'text', [ 'old_text', 'old_flags' ], [ 'old_id' => $textId ], @@ -1792,7 +1792,7 @@ class Revision implements IDBAccessObject { static function getTimestampFromId( $title, $id, $flags = 0 ) { $db = ( $flags & self::READ_LATEST ) ? wfGetDB( DB_MASTER ) - : wfGetDB( DB_SLAVE ); + : wfGetDB( DB_REPLICA ); // Casting fix for databases that can't take '' for rev_id if ( $id == '' ) { $id = 0; @@ -1919,7 +1919,7 @@ class Revision implements IDBAccessObject { } $this->mRefreshMutableFields = false; - $dbr = wfGetLB( $this->mWiki )->getConnectionRef( DB_SLAVE, [], $this->mWiki ); + $dbr = wfGetLB( $this->mWiki )->getConnectionRef( DB_REPLICA, [], $this->mWiki ); $row = $dbr->selectRow( [ 'revision', 'user' ], [ 'rev_deleted', 'user_name' ], diff --git a/includes/RevisionList.php b/includes/RevisionList.php index 811870c8c0..fb444bdd3d 100644 --- a/includes/RevisionList.php +++ b/includes/RevisionList.php @@ -81,7 +81,7 @@ abstract class RevisionListBase extends ContextSource implements Iterator { */ public function reset() { if ( !$this->res ) { - $this->res = $this->doQuery( wfGetDB( DB_SLAVE ) ); + $this->res = $this->doQuery( wfGetDB( DB_REPLICA ) ); } else { $this->res->rewind(); } diff --git a/includes/SiteStats.php b/includes/SiteStats.php index 9507864e41..ff7875c948 100644 --- a/includes/SiteStats.php +++ b/includes/SiteStats.php @@ -59,7 +59,7 @@ class SiteStats { # Update schema $u = new SiteStatsUpdate( 0, 0, 0 ); $u->doUpdate(); - self::$row = self::doLoad( wfGetDB( DB_SLAVE ) ); + self::$row = self::doLoad( wfGetDB( DB_REPLICA ) ); } self::$loaded = true; @@ -72,7 +72,7 @@ class SiteStats { global $wgMiserMode; wfDebug( __METHOD__ . ": reading site_stats from replica DB\n" ); - $row = self::doLoad( wfGetDB( DB_SLAVE ) ); + $row = self::doLoad( wfGetDB( DB_REPLICA ) ); if ( !self::isSane( $row ) ) { // Might have just been initialized during this request? Underflow? @@ -87,7 +87,7 @@ class SiteStats { // clean schema with mwdumper. wfDebug( __METHOD__ . ": initializing damaged or missing site_stats\n" ); - SiteStatsInit::doAllAndCommit( wfGetDB( DB_SLAVE ) ); + SiteStatsInit::doAllAndCommit( wfGetDB( DB_REPLICA ) ); $row = self::doLoad( wfGetDB( DB_MASTER ) ); } @@ -186,7 +186,7 @@ class SiteStats { wfMemcKey( 'SiteStats', 'groupcounts', $group ), $cache::TTL_HOUR, function ( $oldValue, &$ttl, array &$setOpts ) use ( $group ) { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $setOpts += Database::getCacheSetOptions( $dbr ); @@ -229,7 +229,7 @@ class SiteStats { */ static function pagesInNs( $ns ) { if ( !isset( self::$pageCount[$ns] ) ) { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); self::$pageCount[$ns] = (int)$dbr->selectField( 'page', 'COUNT(*)', @@ -296,7 +296,7 @@ class SiteStatsInit { } elseif ( $database ) { $this->db = wfGetDB( DB_MASTER ); } else { - $this->db = wfGetDB( DB_SLAVE, 'vslow' ); + $this->db = wfGetDB( DB_REPLICA, 'vslow' ); } } diff --git a/includes/Title.php b/includes/Title.php index d95a379d25..24bad815ea 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -394,7 +394,7 @@ class Title implements LinkTarget { * @return Title|null The new object, or null on an error */ public static function newFromID( $id, $flags = 0 ) { - $db = ( $flags & self::GAID_FOR_UPDATE ) ? wfGetDB( DB_MASTER ) : wfGetDB( DB_SLAVE ); + $db = ( $flags & self::GAID_FOR_UPDATE ) ? wfGetDB( DB_MASTER ) : wfGetDB( DB_REPLICA ); $row = $db->selectRow( 'page', self::getSelectFields(), @@ -419,7 +419,7 @@ class Title implements LinkTarget { if ( !count( $ids ) ) { return []; } - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $res = $dbr->select( 'page', @@ -561,7 +561,7 @@ class Title implements LinkTarget { * @return Title|null An object representing the article, or null if no such article was found */ public static function nameOf( $id ) { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $s = $dbr->selectRow( 'page', @@ -2540,7 +2540,7 @@ class Title implements LinkTarget { } if ( $this->mTitleProtection === null ) { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $res = $dbr->select( 'protected_titles', [ @@ -2708,7 +2708,7 @@ class Title implements LinkTarget { return [ $this->mHasCascadingRestrictions, $pagerestrictions ]; } - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); if ( $this->getNamespace() == NS_FILE ) { $tables = [ 'imagelinks', 'page_restrictions' ]; @@ -2875,7 +2875,7 @@ class Title implements LinkTarget { * restrictions from page table (pre 1.10) */ public function loadRestrictionsFromRows( $rows, $oldFashionedRestrictions = null ) { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $restrictionTypes = $this->getRestrictionTypes(); @@ -2949,7 +2949,7 @@ class Title implements LinkTarget { */ public function loadRestrictions( $oldFashionedRestrictions = null ) { if ( !$this->mRestrictionsLoaded ) { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); if ( $this->exists() ) { $res = $dbr->select( 'page_restrictions', @@ -3069,7 +3069,7 @@ class Title implements LinkTarget { return []; } - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $conds['page_namespace'] = $this->getNamespace(); $conds[] = 'page_title ' . $dbr->buildLike( $this->getDBkey() . '/', $dbr->anyString() ); $options = []; @@ -3096,7 +3096,7 @@ class Title implements LinkTarget { if ( $this->getNamespace() < 0 ) { $n = 0; } else { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $n = $dbr->selectField( 'archive', 'COUNT(*)', [ 'ar_namespace' => $this->getNamespace(), 'ar_title' => $this->getDBkey() ], @@ -3121,7 +3121,7 @@ class Title implements LinkTarget { if ( $this->getNamespace() < 0 ) { return false; } - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $deleted = (bool)$dbr->selectField( 'archive', '1', [ 'ar_namespace' => $this->getNamespace(), 'ar_title' => $this->getDBkey() ], __METHOD__ @@ -3375,7 +3375,7 @@ class Title implements LinkTarget { if ( count( $options ) > 0 ) { $db = wfGetDB( DB_MASTER ); } else { - $db = wfGetDB( DB_SLAVE ); + $db = wfGetDB( DB_REPLICA ); } $res = $db->select( @@ -3437,7 +3437,7 @@ class Title implements LinkTarget { return []; } - $db = wfGetDB( DB_SLAVE ); + $db = wfGetDB( DB_REPLICA ); $blNamespace = "{$prefix}_namespace"; $blTitle = "{$prefix}_title"; @@ -3500,7 +3500,7 @@ class Title implements LinkTarget { return []; } - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $res = $dbr->select( [ 'page', 'pagelinks' ], [ 'pl_namespace', 'pl_title' ], @@ -3860,7 +3860,7 @@ class Title implements LinkTarget { return $data; } - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $res = $dbr->select( 'categorylinks', @@ -3928,7 +3928,7 @@ class Title implements LinkTarget { * @return int|bool Old revision ID, or false if none exists */ public function getPreviousRevisionID( $revId, $flags = 0 ) { - $db = ( $flags & self::GAID_FOR_UPDATE ) ? wfGetDB( DB_MASTER ) : wfGetDB( DB_SLAVE ); + $db = ( $flags & self::GAID_FOR_UPDATE ) ? wfGetDB( DB_MASTER ) : wfGetDB( DB_REPLICA ); $revId = $db->selectField( 'revision', 'rev_id', [ 'rev_page' => $this->getArticleID( $flags ), @@ -3953,7 +3953,7 @@ class Title implements LinkTarget { * @return int|bool Next revision ID, or false if none exists */ public function getNextRevisionID( $revId, $flags = 0 ) { - $db = ( $flags & self::GAID_FOR_UPDATE ) ? wfGetDB( DB_MASTER ) : wfGetDB( DB_SLAVE ); + $db = ( $flags & self::GAID_FOR_UPDATE ) ? wfGetDB( DB_MASTER ) : wfGetDB( DB_REPLICA ); $revId = $db->selectField( 'revision', 'rev_id', [ 'rev_page' => $this->getArticleID( $flags ), @@ -3979,7 +3979,7 @@ class Title implements LinkTarget { public function getFirstRevision( $flags = 0 ) { $pageId = $this->getArticleID( $flags ); if ( $pageId ) { - $db = ( $flags & self::GAID_FOR_UPDATE ) ? wfGetDB( DB_MASTER ) : wfGetDB( DB_SLAVE ); + $db = ( $flags & self::GAID_FOR_UPDATE ) ? wfGetDB( DB_MASTER ) : wfGetDB( DB_REPLICA ); $row = $db->selectRow( 'revision', Revision::selectFields(), [ 'rev_page' => $pageId ], __METHOD__, @@ -4009,7 +4009,7 @@ class Title implements LinkTarget { * @return bool */ public function isNewPage() { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); return (bool)$dbr->selectField( 'page', 'page_is_new', $this->pageCond(), __METHOD__ ); } @@ -4026,7 +4026,7 @@ class Title implements LinkTarget { } if ( $this->mIsBigDeletion === null ) { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $revCount = $dbr->selectRowCount( 'revision', @@ -4053,7 +4053,7 @@ class Title implements LinkTarget { } if ( $this->mEstimateRevisions === null ) { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $this->mEstimateRevisions = $dbr->estimateRowCount( 'revision', '*', [ 'rev_page' => $this->getArticleID() ], __METHOD__ ); } @@ -4080,7 +4080,7 @@ class Title implements LinkTarget { if ( !$old || !$new ) { return 0; // nothing to compare } - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $conds = [ 'rev_page' => $this->getArticleID(), 'rev_timestamp > ' . $dbr->addQuotes( $dbr->timestamp( $old->getTimestamp() ) ), @@ -4158,7 +4158,7 @@ class Title implements LinkTarget { } return $authors; } - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $res = $dbr->select( 'revision', 'DISTINCT rev_user_text', [ 'rev_page' => $this->getArticleID(), @@ -4413,7 +4413,7 @@ class Title implements LinkTarget { */ public function getTouched( $db = null ) { if ( $db === null ) { - $db = wfGetDB( DB_SLAVE ); + $db = wfGetDB( DB_REPLICA ); } $touched = $db->selectField( 'page', 'page_touched', $this->pageCond(), __METHOD__ ); return $touched; @@ -4497,7 +4497,7 @@ class Title implements LinkTarget { public function getRedirectsHere( $ns = null ) { $redirs = []; - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $where = [ 'rd_namespace' => $this->getNamespace(), 'rd_title' => $this->getDBkey(), diff --git a/includes/WatchedItemQueryService.php b/includes/WatchedItemQueryService.php index 3dcd30f006..4ac4deaa0a 100644 --- a/includes/WatchedItemQueryService.php +++ b/includes/WatchedItemQueryService.php @@ -59,7 +59,7 @@ class WatchedItemQueryService { * @throws MWException */ private function getConnection() { - return $this->loadBalancer->getConnection( DB_SLAVE, [ 'watchlist' ] ); + return $this->loadBalancer->getConnection( DB_REPLICA, [ 'watchlist' ] ); } /** diff --git a/includes/WatchedItemStore.php b/includes/WatchedItemStore.php index a13609bf5d..6986a2f892 100644 --- a/includes/WatchedItemStore.php +++ b/includes/WatchedItemStore.php @@ -190,7 +190,7 @@ class WatchedItemStore implements StatsdAwareInterface { } /** - * @param int $slaveOrMaster DB_MASTER or DB_SLAVE + * @param int $slaveOrMaster DB_MASTER or DB_REPLICA * * @return DatabaseBase * @throws MWException @@ -217,7 +217,7 @@ class WatchedItemStore implements StatsdAwareInterface { * @return int */ public function countWatchedItems( User $user ) { - $dbr = $this->getConnection( DB_SLAVE ); + $dbr = $this->getConnection( DB_REPLICA ); $return = (int)$dbr->selectField( 'watchlist', 'COUNT(*)', @@ -237,7 +237,7 @@ class WatchedItemStore implements StatsdAwareInterface { * @return int */ public function countWatchers( LinkTarget $target ) { - $dbr = $this->getConnection( DB_SLAVE ); + $dbr = $this->getConnection( DB_REPLICA ); $return = (int)$dbr->selectField( 'watchlist', 'COUNT(*)', @@ -263,7 +263,7 @@ class WatchedItemStore implements StatsdAwareInterface { * @throws MWException */ public function countVisitingWatchers( LinkTarget $target, $threshold ) { - $dbr = $this->getConnection( DB_SLAVE ); + $dbr = $this->getConnection( DB_REPLICA ); $visitingWatchers = (int)$dbr->selectField( 'watchlist', 'COUNT(*)', @@ -293,7 +293,7 @@ class WatchedItemStore implements StatsdAwareInterface { public function countWatchersMultiple( array $targets, array $options = [] ) { $dbOptions = [ 'GROUP BY' => [ 'wl_namespace', 'wl_title' ] ]; - $dbr = $this->getConnection( DB_SLAVE ); + $dbr = $this->getConnection( DB_REPLICA ); if ( array_key_exists( 'minimumWatchers', $options ) ) { $dbOptions['HAVING'] = 'COUNT(*) >= ' . (int)$options['minimumWatchers']; @@ -341,7 +341,7 @@ class WatchedItemStore implements StatsdAwareInterface { array $targetsWithVisitThresholds, $minimumWatchers = null ) { - $dbr = $this->getConnection( DB_SLAVE ); + $dbr = $this->getConnection( DB_REPLICA ); $conds = $this->getVisitingWatchersCondition( $dbr, $targetsWithVisitThresholds ); @@ -452,7 +452,7 @@ class WatchedItemStore implements StatsdAwareInterface { return false; } - $dbr = $this->getConnection( DB_SLAVE ); + $dbr = $this->getConnection( DB_REPLICA ); $row = $dbr->selectRow( 'watchlist', 'wl_notificationtimestamp', @@ -499,7 +499,7 @@ class WatchedItemStore implements StatsdAwareInterface { "wl_title {$options['sort']}" ]; } - $db = $this->getConnection( $options['forWrite'] ? DB_MASTER : DB_SLAVE ); + $db = $this->getConnection( $options['forWrite'] ? DB_MASTER : DB_REPLICA ); $res = $db->select( 'watchlist', @@ -569,7 +569,7 @@ class WatchedItemStore implements StatsdAwareInterface { return $timestamps; } - $dbr = $this->getConnection( DB_SLAVE ); + $dbr = $this->getConnection( DB_REPLICA ); $lb = new LinkBatch( $targetsToLoad ); $res = $dbr->select( @@ -885,7 +885,7 @@ class WatchedItemStore implements StatsdAwareInterface { $queryOptions['LIMIT'] = $unreadLimit; } - $dbr = $this->getConnection( DB_SLAVE ); + $dbr = $this->getConnection( DB_REPLICA ); $rowCount = $dbr->selectRowCount( 'watchlist', '1', diff --git a/includes/actions/HistoryAction.php b/includes/actions/HistoryAction.php index 0df372efa3..41378fb693 100644 --- a/includes/actions/HistoryAction.php +++ b/includes/actions/HistoryAction.php @@ -234,7 +234,7 @@ class HistoryAction extends FormlessAction { return new FakeResultWrapper( [] ); } - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); if ( $direction === self::DIR_PREV ) { list( $dirs, $oper ) = [ "ASC", ">=" ]; diff --git a/includes/actions/InfoAction.php b/includes/actions/InfoAction.php index ea66900f69..43bff876ee 100644 --- a/includes/actions/InfoAction.php +++ b/includes/actions/InfoAction.php @@ -676,8 +676,8 @@ class InfoAction extends FormlessAction { $title = $page->getTitle(); $id = $title->getArticleID(); - $dbr = wfGetDB( DB_SLAVE ); - $dbrWatchlist = wfGetDB( DB_SLAVE, 'watchlist' ); + $dbr = wfGetDB( DB_REPLICA ); + $dbrWatchlist = wfGetDB( DB_REPLICA, 'watchlist' ); $setOpts += Database::getCacheSetOptions( $dbr, $dbrWatchlist ); diff --git a/includes/api/ApiBase.php b/includes/api/ApiBase.php index 4ce0ab5743..f763e45ea4 100644 --- a/includes/api/ApiBase.php +++ b/includes/api/ApiBase.php @@ -604,7 +604,7 @@ abstract class ApiBase extends ContextSource { */ protected function getDB() { if ( !isset( $this->mSlaveDB ) ) { - $this->mSlaveDB = wfGetDB( DB_SLAVE, 'api' ); + $this->mSlaveDB = wfGetDB( DB_REPLICA, 'api' ); } return $this->mSlaveDB; diff --git a/includes/api/ApiQueryUserContributions.php b/includes/api/ApiQueryUserContributions.php index 35723e06fd..f92a916f6c 100644 --- a/includes/api/ApiQueryUserContributions.php +++ b/includes/api/ApiQueryUserContributions.php @@ -63,7 +63,7 @@ class ApiQueryContributions extends ApiQueryBase { $dbSecondary = $this->getDB(); // any random replica DB // TODO: if the query is going only against the revision table, should this be done? - $this->selectNamedDB( 'contributions', DB_SLAVE, 'contributions' ); + $this->selectNamedDB( 'contributions', DB_REPLICA, 'contributions' ); $this->idMode = false; if ( isset( $this->params['userprefix'] ) ) { diff --git a/includes/api/ApiQueryWatchlist.php b/includes/api/ApiQueryWatchlist.php index e2599d1d8e..c30f0cf467 100644 --- a/includes/api/ApiQueryWatchlist.php +++ b/includes/api/ApiQueryWatchlist.php @@ -57,7 +57,7 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase { * @return void */ private function run( $resultPageSet = null ) { - $this->selectNamedDB( 'watchlist', DB_SLAVE, 'watchlist' ); + $this->selectNamedDB( 'watchlist', DB_REPLICA, 'watchlist' ); $params = $this->extractRequestParams(); diff --git a/includes/api/ApiStashEdit.php b/includes/api/ApiStashEdit.php index 297c0fb305..bbfc17a525 100644 --- a/includes/api/ApiStashEdit.php +++ b/includes/api/ApiStashEdit.php @@ -313,7 +313,7 @@ class ApiStashEdit extends ApiBase { * @return string|null TS_MW timestamp or null */ private static function lastEditTime( User $user ) { - $time = wfGetDB( DB_SLAVE )->selectField( + $time = wfGetDB( DB_REPLICA )->selectField( 'recentchanges', 'MAX(rc_timestamp)', [ 'rc_user_text' => $user->getName() ], diff --git a/includes/api/ApiTag.php b/includes/api/ApiTag.php index c2d1e0d29d..f88c2dbc62 100644 --- a/includes/api/ApiTag.php +++ b/includes/api/ApiTag.php @@ -63,7 +63,7 @@ class ApiTag extends ApiBase { } protected static function validateLogId( $logid ) { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $result = $dbr->selectField( 'logging', 'log_id', [ 'log_id' => $logid ], __METHOD__ ); return (bool)$result; diff --git a/includes/auth/TemporaryPasswordPrimaryAuthenticationProvider.php b/includes/auth/TemporaryPasswordPrimaryAuthenticationProvider.php index c3382847b5..f5571c7309 100644 --- a/includes/auth/TemporaryPasswordPrimaryAuthenticationProvider.php +++ b/includes/auth/TemporaryPasswordPrimaryAuthenticationProvider.php @@ -126,7 +126,7 @@ class TemporaryPasswordPrimaryAuthenticationProvider return AuthenticationResponse::newAbstain(); } - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $row = $dbr->selectRow( 'user', [ @@ -165,7 +165,7 @@ class TemporaryPasswordPrimaryAuthenticationProvider return false; } - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $row = $dbr->selectRow( 'user', [ 'user_newpassword', 'user_newpass_time' ], diff --git a/includes/cache/BacklinkCache.php b/includes/cache/BacklinkCache.php index a51681910b..9dfabfd089 100644 --- a/includes/cache/BacklinkCache.php +++ b/includes/cache/BacklinkCache.php @@ -143,7 +143,7 @@ class BacklinkCache { */ protected function getDB() { if ( !isset( $this->db ) ) { - $this->db = wfGetDB( DB_SLAVE ); + $this->db = wfGetDB( DB_REPLICA ); } return $this->db; diff --git a/includes/cache/GenderCache.php b/includes/cache/GenderCache.php index 80f04ce621..a34d23586a 100644 --- a/includes/cache/GenderCache.php +++ b/includes/cache/GenderCache.php @@ -157,7 +157,7 @@ class GenderCache { return; } - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $table = [ 'user', 'user_properties' ]; $fields = [ 'user_name', 'up_value' ]; $conds = [ 'user_name' => $usersToCheck ]; diff --git a/includes/cache/LinkBatch.php b/includes/cache/LinkBatch.php index ec37dd61c3..e6d8630c53 100644 --- a/includes/cache/LinkBatch.php +++ b/includes/cache/LinkBatch.php @@ -188,7 +188,7 @@ class LinkBatch { } // This is similar to LinkHolderArray::replaceInternal - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $table = 'page'; $fields = array_merge( LinkCache::getSelectFields(), diff --git a/includes/cache/LinkCache.php b/includes/cache/LinkCache.php index 3fd29f3270..6a602dfb2f 100644 --- a/includes/cache/LinkCache.php +++ b/includes/cache/LinkCache.php @@ -245,7 +245,7 @@ class LinkCache { } // Some fields heavily used for linking... - $db = $this->mForUpdate ? wfGetDB( DB_MASTER ) : wfGetDB( DB_SLAVE ); + $db = $this->mForUpdate ? wfGetDB( DB_MASTER ) : wfGetDB( DB_REPLICA ); $row = $db->selectRow( 'page', self::getSelectFields(), [ 'page_namespace' => $nt->getNamespace(), 'page_title' => $nt->getDBkey() ], diff --git a/includes/cache/MessageBlobStore.php b/includes/cache/MessageBlobStore.php index f1fe54213d..90ad24192d 100644 --- a/includes/cache/MessageBlobStore.php +++ b/includes/cache/MessageBlobStore.php @@ -165,7 +165,7 @@ class MessageBlobStore implements LoggerAwareInterface { $cache->set( $cacheKey, $blob, // Add part of a day to TTL to avoid all modules expiring at once $cache::TTL_WEEK + mt_rand( 0, $cache::TTL_DAY ), - Database::getCacheSetOptions( wfGetDB( DB_SLAVE ) ) + Database::getCacheSetOptions( wfGetDB( DB_REPLICA ) ) ); return $blob; } diff --git a/includes/cache/MessageCache.php b/includes/cache/MessageCache.php index e52670203b..d254d3d536 100644 --- a/includes/cache/MessageCache.php +++ b/includes/cache/MessageCache.php @@ -442,7 +442,7 @@ class MessageCache { function loadFromDB( $code, $mode = null ) { global $wgMaxMsgCacheEntrySize, $wgLanguageCode, $wgAdaptiveMessageCache; - $dbr = wfGetDB( ( $mode == self::FOR_UPDATE ) ? DB_MASTER : DB_SLAVE ); + $dbr = wfGetDB( ( $mode == self::FOR_UPDATE ) ? DB_MASTER : DB_REPLICA ); $cache = []; diff --git a/includes/cache/UserCache.php b/includes/cache/UserCache.php index 48d0398970..016306aff8 100644 --- a/includes/cache/UserCache.php +++ b/includes/cache/UserCache.php @@ -100,7 +100,7 @@ class UserCache { // Lookup basic info for users not yet loaded... if ( count( $usersToQuery ) ) { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $table = [ 'user' ]; $conds = [ 'user_id' => $usersToQuery ]; $fields = [ 'user_name', 'user_real_name', 'user_registration', 'user_id' ]; diff --git a/includes/cache/localisation/LCStoreDB.php b/includes/cache/localisation/LCStoreDB.php index c3501782b4..e7e2d10308 100644 --- a/includes/cache/localisation/LCStoreDB.php +++ b/includes/cache/localisation/LCStoreDB.php @@ -39,7 +39,7 @@ class LCStoreDB implements LCStore { if ( $this->writesDone && $this->dbw ) { $db = $this->dbw; // see the changes in finishWrite() } else { - $db = wfGetDB( DB_SLAVE ); + $db = wfGetDB( DB_REPLICA ); } $value = $db->selectField( diff --git a/includes/changes/RecentChange.php b/includes/changes/RecentChange.php index daf76dfedd..df75ae389e 100644 --- a/includes/changes/RecentChange.php +++ b/includes/changes/RecentChange.php @@ -180,7 +180,7 @@ class RecentChange { public static function newFromConds( $conds, $fname = __METHOD__, - $dbType = DB_SLAVE + $dbType = DB_REPLICA ) { $db = wfGetDB( $dbType ); $row = $db->selectRow( 'recentchanges', self::selectFields(), $conds, $fname ); diff --git a/includes/changetags/ChangeTags.php b/includes/changetags/ChangeTags.php index 4b5c6a2423..c8c50736d0 100644 --- a/includes/changetags/ChangeTags.php +++ b/includes/changetags/ChangeTags.php @@ -633,7 +633,7 @@ class ChangeTags { throw new MWException( 'Unable to determine appropriate JOIN condition for tagging.' ); } - $fields['ts_tags'] = wfGetDB( DB_SLAVE )->buildGroupConcatField( + $fields['ts_tags'] = wfGetDB( DB_REPLICA )->buildGroupConcatField( ',', 'change_tag', 'ct_tag', $join_cond ); @@ -1136,7 +1136,7 @@ class ChangeTags { wfMemcKey( 'active-tags' ), WANObjectCache::TTL_MINUTE * 5, function ( $oldValue, &$ttl, array &$setOpts ) { - $setOpts += Database::getCacheSetOptions( wfGetDB( DB_SLAVE ) ); + $setOpts += Database::getCacheSetOptions( wfGetDB( DB_REPLICA ) ); // Ask extensions which tags they consider active $extensionActive = []; @@ -1181,7 +1181,7 @@ class ChangeTags { wfMemcKey( 'valid-tags-db' ), WANObjectCache::TTL_MINUTE * 5, function ( $oldValue, &$ttl, array &$setOpts ) use ( $fname ) { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $setOpts += Database::getCacheSetOptions( $dbr ); @@ -1211,7 +1211,7 @@ class ChangeTags { wfMemcKey( 'valid-tags-hook' ), WANObjectCache::TTL_MINUTE * 5, function ( $oldValue, &$ttl, array &$setOpts ) { - $setOpts += Database::getCacheSetOptions( wfGetDB( DB_SLAVE ) ); + $setOpts += Database::getCacheSetOptions( wfGetDB( DB_REPLICA ) ); $tags = []; Hooks::run( 'ListDefinedTags', [ &$tags ] ); @@ -1266,7 +1266,7 @@ class ChangeTags { wfMemcKey( 'change-tag-statistics' ), WANObjectCache::TTL_MINUTE * 5, function ( $oldValue, &$ttl, array &$setOpts ) use ( $fname ) { - $dbr = wfGetDB( DB_SLAVE, 'vslow' ); + $dbr = wfGetDB( DB_REPLICA, 'vslow' ); $setOpts += Database::getCacheSetOptions( $dbr ); diff --git a/includes/content/ContentHandler.php b/includes/content/ContentHandler.php index 41fdef5709..22db08a45e 100644 --- a/includes/content/ContentHandler.php +++ b/includes/content/ContentHandler.php @@ -900,7 +900,7 @@ abstract class ContentHandler { * have it / want it. */ public function getAutoDeleteReason( Title $title, &$hasHistory ) { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); // Get the last revision $rev = Revision::newFromTitle( $title ); diff --git a/includes/dao/DBAccessObjectUtils.php b/includes/dao/DBAccessObjectUtils.php index b98174b9ee..1fc9ae784e 100644 --- a/includes/dao/DBAccessObjectUtils.php +++ b/includes/dao/DBAccessObjectUtils.php @@ -40,12 +40,12 @@ class DBAccessObjectUtils { * Get an appropriate DB index and options for a query * * @param integer $bitfield - * @return array (DB_MASTER/DB_SLAVE, SELECT options array) + * @return array (DB_MASTER/DB_REPLICA, SELECT options array) */ public static function getDBOptions( $bitfield ) { $index = self::hasFlags( $bitfield, IDBAccessObject::READ_LATEST ) ? DB_MASTER - : DB_SLAVE; + : DB_REPLICA; $options = []; if ( self::hasFlags( $bitfield, IDBAccessObject::READ_EXCLUSIVE ) ) { diff --git a/includes/db/loadbalancer/LoadBalancer.php b/includes/db/loadbalancer/LoadBalancer.php index e009256ece..d29f05a440 100644 --- a/includes/db/loadbalancer/LoadBalancer.php +++ b/includes/db/loadbalancer/LoadBalancer.php @@ -371,7 +371,7 @@ class LoadBalancer { /** * Set the master wait position - * If a DB_SLAVE connection has been opened already, waits + * If a DB_REPLICA connection has been opened already, waits * Otherwise sets a variable telling it to wait if such a connection is opened * @param DBMasterPos $pos */ @@ -561,7 +561,7 @@ class LoadBalancer { } # Operation-based index - if ( $i == DB_SLAVE ) { + if ( $i == DB_REPLICA ) { $this->mLastError = 'Unknown error'; // reset error string # Try the general server pool if $groups are unavailable. $i = in_array( false, $groups, true ) @@ -612,7 +612,7 @@ class LoadBalancer { /** * This can happen in code like: * foreach ( $dbs as $db ) { - * $conn = $lb->getConnection( DB_SLAVE, [], $db ); + * $conn = $lb->getConnection( DB_REPLICA, [], $db ); * ... * $lb->reuseConnection( $conn ); * } @@ -1429,7 +1429,7 @@ class LoadBalancer { if ( !$this->laggedReplicaMode && $this->getServerCount() > 1 ) { try { // See if laggedReplicaMode gets set - $conn = $this->getConnection( DB_SLAVE, false, $wiki ); + $conn = $this->getConnection( DB_REPLICA, false, $wiki ); $this->reuseConnection( $conn ); } catch ( DBConnectionError $e ) { // Avoid expensive re-connect attempts and failures diff --git a/includes/deferred/SiteStatsUpdate.php b/includes/deferred/SiteStatsUpdate.php index 30aae153dd..d8bc35b2f5 100644 --- a/includes/deferred/SiteStatsUpdate.php +++ b/includes/deferred/SiteStatsUpdate.php @@ -133,7 +133,7 @@ class SiteStatsUpdate implements DeferrableUpdate { */ public static function cacheUpdate( $dbw ) { global $wgActiveUserDays; - $dbr = wfGetDB( DB_SLAVE, 'vslow' ); + $dbr = wfGetDB( DB_REPLICA, 'vslow' ); # Get non-bot users than did some recent action other than making accounts. # If account creation is included, the number gets inflated ~20+ fold on enwiki. $activeUsers = $dbr->selectField( diff --git a/includes/diff/DifferenceEngine.php b/includes/diff/DifferenceEngine.php index baec396ed0..4ebf7ada90 100644 --- a/includes/diff/DifferenceEngine.php +++ b/includes/diff/DifferenceEngine.php @@ -180,7 +180,7 @@ class DifferenceEngine extends ContextSource { */ public function deletedLink( $id ) { if ( $this->getUser()->isAllowed( 'deletedhistory' ) ) { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $row = $dbr->selectRow( 'archive', '*', [ 'ar_rev_id' => $id ], __METHOD__ ); @@ -528,7 +528,7 @@ class DifferenceEngine extends ContextSource { RecentChange::isInRCLifespan( $this->mNewRev->getTimestamp(), 21600 ) ) { // Look for an unpatrolled change corresponding to this diff - $db = wfGetDB( DB_SLAVE ); + $db = wfGetDB( DB_REPLICA ); $change = RecentChange::newFromConds( [ 'rc_timestamp' => $db->timestamp( $this->mNewRev->getTimestamp() ), @@ -1338,7 +1338,7 @@ class DifferenceEngine extends ContextSource { } // Load tags information for both revisions - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); if ( $this->mOldid !== false ) { $this->mOldTags = $dbr->selectField( 'tag_summary', diff --git a/includes/externalstore/ExternalStoreDB.php b/includes/externalstore/ExternalStoreDB.php index 161a7885d7..2eae279be5 100644 --- a/includes/externalstore/ExternalStoreDB.php +++ b/includes/externalstore/ExternalStoreDB.php @@ -130,7 +130,7 @@ class ExternalStoreDB extends ExternalStoreMedium { wfDebug( "writable external store\n" ); } - $db = $lb->getConnection( DB_SLAVE, [], $wiki ); + $db = $lb->getConnection( DB_REPLICA, [], $wiki ); $db->clearFlag( DBO_TRX ); // sanity return $db; diff --git a/includes/filerepo/FileBackendDBRepoWrapper.php b/includes/filerepo/FileBackendDBRepoWrapper.php index aec337e404..106522397a 100644 --- a/includes/filerepo/FileBackendDBRepoWrapper.php +++ b/includes/filerepo/FileBackendDBRepoWrapper.php @@ -94,7 +94,7 @@ class FileBackendDBRepoWrapper extends FileBackend { * @return array Translated paths in same order */ public function getBackendPaths( array $paths, $latest = true ) { - $db = $this->getDB( $latest ? DB_MASTER : DB_SLAVE ); + $db = $this->getDB( $latest ? DB_MASTER : DB_REPLICA ); // @TODO: batching $resolved = []; diff --git a/includes/filerepo/ForeignDBViaLBRepo.php b/includes/filerepo/ForeignDBViaLBRepo.php index a59ca34a04..f8b1ed9f79 100644 --- a/includes/filerepo/ForeignDBViaLBRepo.php +++ b/includes/filerepo/ForeignDBViaLBRepo.php @@ -63,7 +63,7 @@ class ForeignDBViaLBRepo extends LocalRepo { * @return IDatabase */ function getSlaveDB() { - return wfGetDB( DB_SLAVE, [], $this->wiki ); + return wfGetDB( DB_REPLICA, [], $this->wiki ); } /** diff --git a/includes/filerepo/LocalRepo.php b/includes/filerepo/LocalRepo.php index b108e00b41..fccb755eef 100644 --- a/includes/filerepo/LocalRepo.php +++ b/includes/filerepo/LocalRepo.php @@ -457,7 +457,7 @@ class LocalRepo extends FileRepo { * @return DatabaseBase */ function getSlaveDB() { - return wfGetDB( DB_SLAVE ); + return wfGetDB( DB_REPLICA ); } /** @@ -469,7 +469,7 @@ class LocalRepo extends FileRepo { } /** - * Get a callback to get a DB handle given an index (DB_SLAVE/DB_MASTER) + * Get a callback to get a DB handle given an index (DB_REPLICA/DB_MASTER) * @return Closure */ protected function getDBFactory() { diff --git a/includes/filerepo/file/ArchivedFile.php b/includes/filerepo/file/ArchivedFile.php index ca1ea84827..d1e683ac70 100644 --- a/includes/filerepo/file/ArchivedFile.php +++ b/includes/filerepo/file/ArchivedFile.php @@ -177,7 +177,7 @@ class ArchivedFile { if ( !$this->title || $this->title->getNamespace() == NS_FILE ) { $this->dataLoaded = true; // set it here, to have also true on miss - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $row = $dbr->selectRow( 'filearchive', self::selectFields(), diff --git a/includes/interwiki/ClassicInterwikiLookup.php b/includes/interwiki/ClassicInterwikiLookup.php index f7205f4fca..0e107b3d11 100644 --- a/includes/interwiki/ClassicInterwikiLookup.php +++ b/includes/interwiki/ClassicInterwikiLookup.php @@ -282,7 +282,7 @@ class ClassicInterwikiLookup implements InterwikiLookup { $this->objectCache->makeKey( 'interwiki', $prefix ), $this->objectCacheExpiry, function ( $oldValue, &$ttl, array &$setOpts ) use ( $prefix ) { - $dbr = wfGetDB( DB_SLAVE ); // TODO: inject LoadBalancer + $dbr = wfGetDB( DB_REPLICA ); // TODO: inject LoadBalancer $setOpts += Database::getCacheSetOptions( $dbr ); @@ -395,7 +395,7 @@ class ClassicInterwikiLookup implements InterwikiLookup { * @return array[] Interwiki rows */ private function getAllPrefixesDB( $local ) { - $db = wfGetDB( DB_SLAVE ); // TODO: inject DB LoadBalancer + $db = wfGetDB( DB_REPLICA ); // TODO: inject DB LoadBalancer $where = []; diff --git a/includes/jobqueue/JobQueueDB.php b/includes/jobqueue/JobQueueDB.php index d981d13a40..f6b4d53db1 100644 --- a/includes/jobqueue/JobQueueDB.php +++ b/includes/jobqueue/JobQueueDB.php @@ -732,7 +732,7 @@ class JobQueueDB extends JobQueue { */ protected function getSlaveDB() { try { - return $this->getDB( DB_SLAVE ); + return $this->getDB( DB_REPLICA ); } catch ( DBConnectionError $e ) { throw new JobQueueConnectionError( "DBConnectionError:" . $e->getMessage() ); } @@ -751,7 +751,7 @@ class JobQueueDB extends JobQueue { } /** - * @param int $index (DB_SLAVE/DB_MASTER) + * @param int $index (DB_REPLICA/DB_MASTER) * @return DBConnRef */ protected function getDB( $index ) { diff --git a/includes/jobqueue/jobs/CategoryMembershipChangeJob.php b/includes/jobqueue/jobs/CategoryMembershipChangeJob.php index 94e7248e60..e6f59f3666 100644 --- a/includes/jobqueue/jobs/CategoryMembershipChangeJob.php +++ b/includes/jobqueue/jobs/CategoryMembershipChangeJob.php @@ -57,7 +57,7 @@ class CategoryMembershipChangeJob extends Job { return false; } - $dbr = wfGetDB( DB_SLAVE, [ 'recentchanges' ] ); + $dbr = wfGetDB( DB_REPLICA, [ 'recentchanges' ] ); // Wait till the replica DB is caught up so that jobs for this page see each others' changes if ( !wfGetLB()->safeWaitForMasterPos( $dbr ) ) { $this->setLastError( "Timed out while waiting for replica DB to catch up" ); diff --git a/includes/libs/objectcache/WANObjectCache.php b/includes/libs/objectcache/WANObjectCache.php index daf963f302..200ddfa276 100644 --- a/includes/libs/objectcache/WANObjectCache.php +++ b/includes/libs/objectcache/WANObjectCache.php @@ -364,7 +364,7 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface { * * Example usage: * @code - * $dbr = wfGetDB( DB_SLAVE ); + * $dbr = wfGetDB( DB_REPLICA ); * $setOpts = Database::getCacheSetOptions( $dbr ); * // Fetch the row from the DB * $row = $dbr->selectRow( ... ); @@ -660,7 +660,7 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface { * $cache::TTL_MINUTE, * // Function that derives the new key value * function ( $oldValue, &$ttl, array &$setOpts ) { - * $dbr = wfGetDB( DB_SLAVE ); + * $dbr = wfGetDB( DB_REPLICA ); * // Account for any snapshot/replica DB lag * $setOpts += Database::getCacheSetOptions( $dbr ); * @@ -678,7 +678,7 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface { * $cache::TTL_DAY, * // Function that derives the new key value * function ( $oldValue, &$ttl, array &$setOpts ) { - * $dbr = wfGetDB( DB_SLAVE ); + * $dbr = wfGetDB( DB_REPLICA ); * // Account for any snapshot/replica DB lag * $setOpts += Database::getCacheSetOptions( $dbr ); * @@ -705,7 +705,7 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface { * // Function that derives the new key value * function ( $oldValue, &$ttl, array &$setOpts ) { * // Determine new value from the DB - * $dbr = wfGetDB( DB_SLAVE ); + * $dbr = wfGetDB( DB_REPLICA ); * // Account for any snapshot/replica DB lag * $setOpts += Database::getCacheSetOptions( $dbr ); * @@ -732,7 +732,7 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface { * 10, * // Function that derives the new key value * function ( $oldValue, &$ttl, array &$setOpts ) { - * $dbr = wfGetDB( DB_SLAVE ); + * $dbr = wfGetDB( DB_REPLICA ); * // Account for any snapshot/replica DB lag * $setOpts += Database::getCacheSetOptions( $dbr ); * diff --git a/includes/logging/LogPager.php b/includes/logging/LogPager.php index eeea789c3e..68163c13e5 100644 --- a/includes/logging/LogPager.php +++ b/includes/logging/LogPager.php @@ -78,7 +78,7 @@ class LogPager extends ReverseChronologicalPager { $this->getDateCond( $year, $month ); $this->mTagFilter = $tagFilter; - $this->mDb = wfGetDB( DB_SLAVE, 'logpager' ); + $this->mDb = wfGetDB( DB_REPLICA, 'logpager' ); } public function getDefaultQuery() { diff --git a/includes/objectcache/SqlBagOStuff.php b/includes/objectcache/SqlBagOStuff.php index 48bbc490fc..4870d5eb70 100644 --- a/includes/objectcache/SqlBagOStuff.php +++ b/includes/objectcache/SqlBagOStuff.php @@ -183,7 +183,7 @@ class SqlBagOStuff extends BagOStuff { $db = DatabaseBase::factory( $type, $info ); $db->clearFlag( DBO_TRX ); } else { - $index = $this->slaveOnly ? DB_SLAVE : DB_MASTER; + $index = $this->slaveOnly ? DB_REPLICA : DB_MASTER; if ( $this->getSeparateMainLB() ) { $db = $this->getSeparateMainLB()->getConnection( $index ); $db->clearFlag( DBO_TRX ); // auto-commit mode diff --git a/includes/page/Article.php b/includes/page/Article.php index c36b5e85c3..449c9ffe58 100644 --- a/includes/page/Article.php +++ b/includes/page/Article.php @@ -1068,7 +1068,7 @@ class Article implements Page { return false; } - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $oldestRevisionTimestamp = $dbr->selectField( 'revision', 'MIN( rev_timestamp )', @@ -1705,7 +1705,7 @@ class Article implements Page { // This, as a side-effect, also makes sure that the following query isn't being run for // pages with a larger history, unless the user has the 'bigdelete' right // (and is about to delete this page). - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $revisions = $edits = (int)$dbr->selectField( 'revision', 'COUNT(rev_page)', diff --git a/includes/page/ImagePage.php b/includes/page/ImagePage.php index 13966851b9..be5535a1f5 100644 --- a/includes/page/ImagePage.php +++ b/includes/page/ImagePage.php @@ -810,7 +810,7 @@ EOT * @return ResultWrapper */ protected function queryImageLinks( $target, $limit ) { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); return $dbr->select( [ 'imagelinks', 'page' ], diff --git a/includes/page/WikiPage.php b/includes/page/WikiPage.php index 4dfbb7a4c2..8c2d59449b 100644 --- a/includes/page/WikiPage.php +++ b/includes/page/WikiPage.php @@ -146,7 +146,7 @@ class WikiPage implements Page, IDBAccessObject { } $from = self::convertSelectType( $from ); - $db = wfGetDB( $from === self::READ_LATEST ? DB_MASTER : DB_SLAVE ); + $db = wfGetDB( $from === self::READ_LATEST ? DB_MASTER : DB_REPLICA ); $row = $db->selectRow( 'page', self::selectFields(), [ 'page_id' => $id ], __METHOD__ ); if ( !$row ) { @@ -365,7 +365,7 @@ class WikiPage implements Page, IDBAccessObject { $data = $this->pageDataFromTitle( wfGetDB( $index ), $this->mTitle, $opts ); if ( !$data - && $index == DB_SLAVE + && $index == DB_REPLICA && wfGetLB()->getServerCount() > 1 && wfGetLB()->hasOrMadeRecentMasterChanges() ) { @@ -554,7 +554,7 @@ class WikiPage implements Page, IDBAccessObject { // Try using the replica DB first, then try the master $continue = 2; - $db = wfGetDB( DB_SLAVE ); + $db = wfGetDB( DB_REPLICA ); $revSelectFields = Revision::selectFields(); $row = null; @@ -831,7 +831,7 @@ class WikiPage implements Page, IDBAccessObject { // links. $hasLinks = (bool)count( $editInfo->output->getLinks() ); } else { - $hasLinks = (bool)wfGetDB( DB_SLAVE )->selectField( 'pagelinks', 1, + $hasLinks = (bool)wfGetDB( DB_REPLICA )->selectField( 'pagelinks', 1, [ 'pl_from' => $this->getId() ], __METHOD__ ); } } @@ -856,7 +856,7 @@ class WikiPage implements Page, IDBAccessObject { } // Query the redirect table - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $row = $dbr->selectRow( 'redirect', [ 'rd_namespace', 'rd_title', 'rd_fragment', 'rd_interwiki' ], [ 'rd_from' => $this->getId() ], @@ -989,7 +989,7 @@ class WikiPage implements Page, IDBAccessObject { public function getContributors() { // @todo FIXME: This is expensive; cache this info somewhere. - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); if ( $dbr->implicitGroupby() ) { $realNameField = 'user_real_name'; @@ -1386,7 +1386,7 @@ class WikiPage implements Page, IDBAccessObject { $baseRevId = null; if ( $edittime && $sectionId !== 'new' ) { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $rev = Revision::loadFromTimestamp( $dbr, $this->mTitle, $edittime ); // Try the master if this thread may have just added it. // This could be abstracted into a Revision method, but we don't want @@ -3414,7 +3414,7 @@ class WikiPage implements Page, IDBAccessObject { return TitleArray::newFromResult( new FakeResultWrapper( [] ) ); } - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $res = $dbr->select( 'categorylinks', [ 'cl_to AS page_title, ' . NS_CATEGORY . ' AS page_namespace' ], // Have to do that since DatabaseBase::fieldNamesWithAlias treats numeric indexes @@ -3439,7 +3439,7 @@ class WikiPage implements Page, IDBAccessObject { return []; } - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $res = $dbr->select( [ 'categorylinks', 'page_props', 'page' ], [ 'cl_to' ], [ 'cl_from' => $id, 'pp_page=page_id', 'pp_propname' => 'hiddencat', diff --git a/includes/pager/IndexPager.php b/includes/pager/IndexPager.php index 183e4f21b5..395cee5b80 100644 --- a/includes/pager/IndexPager.php +++ b/includes/pager/IndexPager.php @@ -146,7 +146,7 @@ abstract class IndexPager extends ContextSource implements Pager { $this->mIsBackwards = ( $this->mRequest->getVal( 'dir' ) == 'prev' ); # Let the subclass set the DB here; otherwise use a replica DB for the current wiki - $this->mDb = $this->mDb ?: wfGetDB( DB_SLAVE ); + $this->mDb = $this->mDb ?: wfGetDB( DB_REPLICA ); $index = $this->getIndexField(); // column to sort on $extraSort = $this->getExtraSortFields(); // extra columns to sort on for query planning diff --git a/includes/parser/LinkHolderArray.php b/includes/parser/LinkHolderArray.php index b34ac1ff46..b32f43b893 100644 --- a/includes/parser/LinkHolderArray.php +++ b/includes/parser/LinkHolderArray.php @@ -289,7 +289,7 @@ class LinkHolderArray { $output = $this->parent->getOutput(); $linkRenderer = $this->parent->getLinkRenderer(); - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); # Sort by namespace ksort( $this->internals ); @@ -534,7 +534,7 @@ class LinkHolderArray { if ( !$linkBatch->isEmpty() ) { // construct query - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $fields = array_merge( LinkCache::getSelectFields(), [ 'page_namespace', 'page_title' ] diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index a93400be02..b53920b0fc 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -3464,7 +3464,7 @@ class Parser { $pageId = $title->getArticleID(); $revId = $title->getLatestRevID(); - $rev = Revision::newKnownCurrent( wfGetDB( DB_SLAVE ), $pageId, $revId ); + $rev = Revision::newKnownCurrent( wfGetDB( DB_REPLICA ), $pageId, $revId ); if ( $rev ) { $rev->setTitle( $title ); } @@ -3684,7 +3684,7 @@ class Parser { */ public function fetchScaryTemplateMaybeFromCache( $url ) { global $wgTranscludeCacheExpiry; - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $tsCond = $dbr->timestamp( time() - $wgTranscludeCacheExpiry ); $obj = $dbr->selectRow( 'transcache', [ 'tc_time', 'tc_contents' ], [ 'tc_url' => $url, "tc_time >= " . $dbr->addQuotes( $tsCond ) ] ); diff --git a/includes/resourceloader/ResourceLoader.php b/includes/resourceloader/ResourceLoader.php index d9cd0ee35b..fa110e3ae4 100644 --- a/includes/resourceloader/ResourceLoader.php +++ b/includes/resourceloader/ResourceLoader.php @@ -109,7 +109,7 @@ class ResourceLoader implements LoggerAwareInterface { // Or else Database*::select() will explode, plus it's cheaper! return; } - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $skin = $context->getSkin(); $lang = $context->getLanguage(); @@ -893,7 +893,7 @@ class ResourceLoader implements LoggerAwareInterface { $good = $fileCache->isCacheGood( wfTimestamp( TS_MW, time() - $maxage ) ); if ( !$good ) { try { // RL always hits the DB on file cache miss... - wfGetDB( DB_SLAVE ); + wfGetDB( DB_REPLICA ); } catch ( DBConnectionError $e ) { // ...check if we need to fallback to cache $good = $fileCache->isCacheGood(); // cache existence check } diff --git a/includes/resourceloader/ResourceLoaderModule.php b/includes/resourceloader/ResourceLoaderModule.php index de89fc7417..43cf78bd59 100644 --- a/includes/resourceloader/ResourceLoaderModule.php +++ b/includes/resourceloader/ResourceLoaderModule.php @@ -417,7 +417,7 @@ abstract class ResourceLoaderModule implements LoggerAwareInterface { // Try in-object cache first if ( !isset( $this->fileDeps[$vary] ) ) { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $deps = $dbr->selectField( 'module_deps', 'md_deps', [ diff --git a/includes/resourceloader/ResourceLoaderWikiModule.php b/includes/resourceloader/ResourceLoaderWikiModule.php index dc74351a82..390f7853ce 100644 --- a/includes/resourceloader/ResourceLoaderWikiModule.php +++ b/includes/resourceloader/ResourceLoaderWikiModule.php @@ -139,7 +139,7 @@ class ResourceLoaderWikiModule extends ResourceLoaderModule { * @return IDatabase|null */ protected function getDB() { - return wfGetDB( DB_SLAVE ); + return wfGetDB( DB_REPLICA ); } /** diff --git a/includes/revisiondelete/RevDelLogList.php b/includes/revisiondelete/RevDelLogList.php index 07fe4a14f9..ff1d2eda1e 100644 --- a/includes/revisiondelete/RevDelLogList.php +++ b/includes/revisiondelete/RevDelLogList.php @@ -40,7 +40,7 @@ class RevDelLogList extends RevDelList { } public static function suggestTarget( $target, array $ids ) { - $result = wfGetDB( DB_SLAVE )->select( 'logging', + $result = wfGetDB( DB_REPLICA )->select( 'logging', 'log_type', [ 'log_id' => $ids ], __METHOD__, diff --git a/includes/revisiondelete/RevisionDeleter.php b/includes/revisiondelete/RevisionDeleter.php index eea0c28b66..b834c15367 100644 --- a/includes/revisiondelete/RevisionDeleter.php +++ b/includes/revisiondelete/RevisionDeleter.php @@ -213,7 +213,7 @@ class RevisionDeleter { * @return bool|mixed */ public static function checkRevisionExistence( $title, $revid ) { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $exists = $dbr->selectField( 'revision', '1', [ 'rev_id' => $revid ], __METHOD__ ); diff --git a/includes/search/SearchDatabase.php b/includes/search/SearchDatabase.php index 5b18b7c82b..38c60d0bec 100644 --- a/includes/search/SearchDatabase.php +++ b/includes/search/SearchDatabase.php @@ -40,7 +40,7 @@ class SearchDatabase extends SearchEngine { if ( $db ) { $this->db = $db; } else { - $this->db = wfGetDB( DB_SLAVE ); + $this->db = wfGetDB( DB_REPLICA ); } } diff --git a/includes/search/SearchEngineFactory.php b/includes/search/SearchEngineFactory.php index 67f500c1ce..e30869e19b 100644 --- a/includes/search/SearchEngineFactory.php +++ b/includes/search/SearchEngineFactory.php @@ -32,7 +32,7 @@ class SearchEngineFactory { } elseif ( $configType !== null ) { $class = $configType; } else { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $class = $dbr->getSearchEngine(); } diff --git a/includes/search/SearchMySQL.php b/includes/search/SearchMySQL.php index 7e823786c2..36cbbaa856 100644 --- a/includes/search/SearchMySQL.php +++ b/includes/search/SearchMySQL.php @@ -437,7 +437,7 @@ class SearchMySQL extends SearchDatabase { if ( is_null( self::$mMinSearchLength ) ) { $sql = "SHOW GLOBAL VARIABLES LIKE 'ft\\_min\\_word\\_len'"; - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $result = $dbr->query( $sql, __METHOD__ ); $row = $result->fetchObject(); $result->free(); diff --git a/includes/site/DBSiteStore.php b/includes/site/DBSiteStore.php index 974789f94f..432d5ce1da 100644 --- a/includes/site/DBSiteStore.php +++ b/includes/site/DBSiteStore.php @@ -73,7 +73,7 @@ class DBSiteStore implements SiteStore { protected function loadSites() { $this->sites = new SiteList(); - $dbr = $this->dbLoadBalancer->getConnection( DB_SLAVE ); + $dbr = $this->dbLoadBalancer->getConnection( DB_REPLICA ); $res = $dbr->select( 'sites', diff --git a/includes/specialpage/ChangesListSpecialPage.php b/includes/specialpage/ChangesListSpecialPage.php index 60f1dd81fa..01782f3b73 100644 --- a/includes/specialpage/ChangesListSpecialPage.php +++ b/includes/specialpage/ChangesListSpecialPage.php @@ -340,7 +340,7 @@ abstract class ChangesListSpecialPage extends SpecialPage { * @return IDatabase */ protected function getDB() { - return wfGetDB( DB_SLAVE ); + return wfGetDB( DB_REPLICA ); } /** diff --git a/includes/specialpage/QueryPage.php b/includes/specialpage/QueryPage.php index 1beac43079..afbc5813a0 100644 --- a/includes/specialpage/QueryPage.php +++ b/includes/specialpage/QueryPage.php @@ -376,7 +376,7 @@ abstract class QueryPage extends SpecialPage { * @return IDatabase */ function getRecacheDB() { - return wfGetDB( DB_SLAVE, [ $this->getName(), 'QueryPage::recache', 'vslow' ] ); + return wfGetDB( DB_REPLICA, [ $this->getName(), 'QueryPage::recache', 'vslow' ] ); } /** @@ -453,7 +453,7 @@ abstract class QueryPage extends SpecialPage { * @since 1.18 */ public function fetchFromCache( $limit, $offset = false ) { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $options = []; if ( $limit !== false ) { $options['LIMIT'] = intval( $limit ); @@ -477,7 +477,7 @@ abstract class QueryPage extends SpecialPage { public function getCachedTimestamp() { if ( is_null( $this->cachedTimestamp ) ) { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $fname = get_class( $this ) . '::getCachedTimestamp'; $this->cachedTimestamp = $dbr->selectField( 'querycache_info', 'qci_timestamp', [ 'qci_type' => $this->getName() ], $fname ); diff --git a/includes/specials/SpecialActiveusers.php b/includes/specials/SpecialActiveusers.php index c697ca7037..2da441b880 100644 --- a/includes/specials/SpecialActiveusers.php +++ b/includes/specials/SpecialActiveusers.php @@ -62,7 +62,7 @@ class SpecialActiveUsers extends SpecialPage { // Mention the level of cache staleness... $cacheText = ''; - $dbr = wfGetDB( DB_SLAVE, 'recentchanges' ); + $dbr = wfGetDB( DB_REPLICA, 'recentchanges' ); $rcMax = $dbr->selectField( 'recentchanges', 'MAX(rc_timestamp)', '', __METHOD__ ); if ( $rcMax ) { $cTime = $dbr->selectField( 'querycache_info', diff --git a/includes/specials/SpecialAllPages.php b/includes/specials/SpecialAllPages.php index b55f0b4923..4a2a619716 100644 --- a/includes/specials/SpecialAllPages.php +++ b/includes/specials/SpecialAllPages.php @@ -181,7 +181,7 @@ class SpecialAllPages extends IncludableSpecialPage { list( $namespace, $fromKey, $from ) = $fromList; list( , $toKey, $to ) = $toList; - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $filterConds = [ 'page_namespace' => $namespace ]; if ( $hideredirects ) { $filterConds['page_is_redirect'] = 0; diff --git a/includes/specials/SpecialBlockList.php b/includes/specials/SpecialBlockList.php index de58762a7e..c4fb3161e2 100644 --- a/includes/specials/SpecialBlockList.php +++ b/includes/specials/SpecialBlockList.php @@ -136,7 +136,7 @@ class SpecialBlockList extends SpecialPage { case Block::TYPE_IP: case Block::TYPE_RANGE: list( $start, $end ) = IP::parseRange( $target ); - $conds[] = wfGetDB( DB_SLAVE )->makeList( + $conds[] = wfGetDB( DB_REPLICA )->makeList( [ 'ipb_address' => $target, Block::getRangeCond( $start, $end ) diff --git a/includes/specials/SpecialBotPasswords.php b/includes/specials/SpecialBotPasswords.php index 7e330aa63f..61ab642c53 100644 --- a/includes/specials/SpecialBotPasswords.php +++ b/includes/specials/SpecialBotPasswords.php @@ -163,7 +163,7 @@ class SpecialBotPasswords extends FormSpecialPage { } else { $linkRenderer = $this->getLinkRenderer(); - $dbr = BotPassword::getDB( DB_SLAVE ); + $dbr = BotPassword::getDB( DB_REPLICA ); $res = $dbr->select( 'bot_passwords', [ 'bp_app_id' ], diff --git a/includes/specials/SpecialBrokenRedirects.php b/includes/specials/SpecialBrokenRedirects.php index 4c3fbe5b18..b9b20511cf 100644 --- a/includes/specials/SpecialBrokenRedirects.php +++ b/includes/specials/SpecialBrokenRedirects.php @@ -49,7 +49,7 @@ class BrokenRedirectsPage extends QueryPage { } public function getQueryInfo() { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); return [ 'tables' => [ diff --git a/includes/specials/SpecialDoubleRedirects.php b/includes/specials/SpecialDoubleRedirects.php index 7b00064997..0cec9d076c 100644 --- a/includes/specials/SpecialDoubleRedirects.php +++ b/includes/specials/SpecialDoubleRedirects.php @@ -50,7 +50,7 @@ class DoubleRedirectsPage extends QueryPage { function reallyGetQueryInfo( $namespace = null, $title = null ) { $limitToTitle = !( $namespace === null && $title === null ); - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $retval = [ 'tables' => [ 'ra' => 'redirect', @@ -121,7 +121,7 @@ class DoubleRedirectsPage extends QueryPage { // get a little more detail about each individual entry quickly // using the filter of reallyGetQueryInfo. if ( $result && !isset( $result->nsb ) ) { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $qi = $this->reallyGetQueryInfo( $result->namespace, $result->title diff --git a/includes/specials/SpecialExport.php b/includes/specials/SpecialExport.php index fe977398a4..bf535a6f3a 100644 --- a/includes/specials/SpecialExport.php +++ b/includes/specials/SpecialExport.php @@ -370,12 +370,12 @@ class SpecialExport extends SpecialPage { /* Ok, let's get to it... */ if ( $history == WikiExporter::CURRENT ) { $lb = false; - $db = wfGetDB( DB_SLAVE ); + $db = wfGetDB( DB_REPLICA ); $buffer = WikiExporter::BUFFER; } else { // Use an unbuffered query; histories may be very long! $lb = wfGetLBFactory()->newMainLB(); - $db = $lb->getConnection( DB_SLAVE ); + $db = $lb->getConnection( DB_REPLICA ); $buffer = WikiExporter::STREAM; // This might take a while... :D @@ -426,7 +426,7 @@ class SpecialExport extends SpecialPage { $name = $title->getDBkey(); - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $res = $dbr->select( [ 'page', 'categorylinks' ], [ 'page_namespace', 'page_title' ], @@ -459,7 +459,7 @@ class SpecialExport extends SpecialPage { $maxPages = $this->getConfig()->get( 'ExportPagelistLimit' ); - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $res = $dbr->select( 'page', [ 'page_namespace', 'page_title' ], @@ -556,7 +556,7 @@ class SpecialExport extends SpecialPage { * @return array */ private function getLinks( $inputPages, $pageSet, $table, $fields, $join ) { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); foreach ( $inputPages as $page ) { $title = Title::newFromText( $page ); diff --git a/includes/specials/SpecialLinkSearch.php b/includes/specials/SpecialLinkSearch.php index d4886f026b..307d6c3b59 100644 --- a/includes/specials/SpecialLinkSearch.php +++ b/includes/specials/SpecialLinkSearch.php @@ -153,7 +153,7 @@ class LinkSearchPage extends QueryPage { */ static function mungeQuery( $query, $prot ) { $field = 'el_index'; - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); if ( $query === '*' && $prot !== '' ) { // Allow queries like 'ftp://*' to find all ftp links @@ -185,7 +185,7 @@ class LinkSearchPage extends QueryPage { } public function getQueryInfo() { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); // strip everything past first wildcard, so that // index-based-only lookup would be done list( $this->mungedQuery, $clause ) = self::mungeQuery( $this->mQuery, $this->mProt ); diff --git a/includes/specials/SpecialMediaStatistics.php b/includes/specials/SpecialMediaStatistics.php index e51e8b500e..ec877160cf 100644 --- a/includes/specials/SpecialMediaStatistics.php +++ b/includes/specials/SpecialMediaStatistics.php @@ -62,7 +62,7 @@ class MediaStatisticsPage extends QueryPage { * Special:BrokenRedirects also rely on this. */ public function getQueryInfo() { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $fakeTitle = $dbr->buildConcat( [ 'img_media_type', $dbr->addQuotes( ';' ), diff --git a/includes/specials/SpecialMovepage.php b/includes/specials/SpecialMovepage.php index f0b463a1e0..3a12cf3ce3 100644 --- a/includes/specials/SpecialMovepage.php +++ b/includes/specials/SpecialMovepage.php @@ -223,7 +223,7 @@ class MovePageForm extends UnlistedSpecialPage { ( $oldTalk->exists() || ( $oldTitleTalkSubpages && $canMoveSubpage ) ); - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); if ( $this->getConfig()->get( 'FixDoubleRedirects' ) ) { $hasRedirects = $dbr->selectField( 'redirect', '1', [ diff --git a/includes/specials/SpecialPagesWithProp.php b/includes/specials/SpecialPagesWithProp.php index 327ddda414..706a1d7794 100644 --- a/includes/specials/SpecialPagesWithProp.php +++ b/includes/specials/SpecialPagesWithProp.php @@ -174,7 +174,7 @@ class SpecialPagesWithProp extends QueryPage { $opts['OFFSET'] = $offset; } - $res = wfGetDB( DB_SLAVE )->select( + $res = wfGetDB( DB_REPLICA )->select( 'page_props', 'pp_propname', '', diff --git a/includes/specials/SpecialPrefixindex.php b/includes/specials/SpecialPrefixindex.php index 87a5b27be0..5e3e430a2a 100644 --- a/includes/specials/SpecialPrefixindex.php +++ b/includes/specials/SpecialPrefixindex.php @@ -181,7 +181,7 @@ class SpecialPrefixindex extends SpecialAllPages { # ## @todo FIXME: Should complain if $fromNs != $namespace - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $conds = [ 'page_namespace' => $namespace, diff --git a/includes/specials/SpecialRandomInCategory.php b/includes/specials/SpecialRandomInCategory.php index a5e538f161..fc924a4d58 100644 --- a/includes/specials/SpecialRandomInCategory.php +++ b/includes/specials/SpecialRandomInCategory.php @@ -223,7 +223,7 @@ class SpecialRandomInCategory extends FormSpecialPage { ] ]; - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $minClTime = $this->getTimestampOffset( $rand ); if ( $minClTime ) { $qi['conds'][] = 'cl_timestamp ' . $op . ' ' . @@ -264,7 +264,7 @@ class SpecialRandomInCategory extends FormSpecialPage { * @throws MWException If category has no entries. */ protected function getMinAndMaxForCat( Title $category ) { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $res = $dbr->selectRow( 'categorylinks', [ @@ -294,7 +294,7 @@ class SpecialRandomInCategory extends FormSpecialPage { * @return array Info for the title selected. */ private function selectRandomPageFromDB( $rand, $offset, $up, $fname = __METHOD__ ) { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $query = $this->getQueryInfo( $rand, $offset, $up ); $res = $dbr->select( diff --git a/includes/specials/SpecialRandompage.php b/includes/specials/SpecialRandompage.php index d7835d1045..e3b567d7fe 100644 --- a/includes/specials/SpecialRandompage.php +++ b/includes/specials/SpecialRandompage.php @@ -159,7 +159,7 @@ class RandomPage extends SpecialPage { } private function selectRandomPageFromDB( $randstr, $fname = __METHOD__ ) { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $query = $this->getQueryInfo( $randstr ); $res = $dbr->select( diff --git a/includes/specials/SpecialRandomrootpage.php b/includes/specials/SpecialRandomrootpage.php index 31a290d827..0df8423fac 100644 --- a/includes/specials/SpecialRandomrootpage.php +++ b/includes/specials/SpecialRandomrootpage.php @@ -28,7 +28,7 @@ class SpecialRandomrootpage extends RandomPage { public function __construct() { parent::__construct( 'Randomrootpage' ); - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $this->extra[] = 'page_title NOT ' . $dbr->buildLike( $dbr->anyString(), '/', $dbr->anyString() ); } diff --git a/includes/specials/SpecialRecentchanges.php b/includes/specials/SpecialRecentchanges.php index d4fb72ca98..8aff69089c 100644 --- a/includes/specials/SpecialRecentchanges.php +++ b/includes/specials/SpecialRecentchanges.php @@ -281,7 +281,7 @@ class SpecialRecentChanges extends ChangesListSpecialPage { } protected function getDB() { - return wfGetDB( DB_SLAVE, 'recentchanges' ); + return wfGetDB( DB_REPLICA, 'recentchanges' ); } public function outputFeedLinks() { diff --git a/includes/specials/SpecialRecentchangeslinked.php b/includes/specials/SpecialRecentchangeslinked.php index 57a3d929ad..aab0f6dcb0 100644 --- a/includes/specials/SpecialRecentchangeslinked.php +++ b/includes/specials/SpecialRecentchangeslinked.php @@ -74,7 +74,7 @@ class SpecialRecentChangesLinked extends SpecialRecentChanges { * expects only one result set so we use UNION instead. */ - $dbr = wfGetDB( DB_SLAVE, 'recentchangeslinked' ); + $dbr = wfGetDB( DB_REPLICA, 'recentchangeslinked' ); $id = $title->getArticleID(); $ns = $title->getNamespace(); $dbkey = $title->getDBkey(); diff --git a/includes/specials/SpecialRedirect.php b/includes/specials/SpecialRedirect.php index 80dc7977a1..1d1df6a043 100644 --- a/includes/specials/SpecialRedirect.php +++ b/includes/specials/SpecialRedirect.php @@ -182,7 +182,7 @@ class SpecialRedirect extends FormSpecialPage { 'log_user_text', ]; - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); // Gets the nested SQL statement which // returns timestamp of the log with the given log ID diff --git a/includes/specials/SpecialUndelete.php b/includes/specials/SpecialUndelete.php index 65f0680d81..91753a9dbd 100644 --- a/includes/specials/SpecialUndelete.php +++ b/includes/specials/SpecialUndelete.php @@ -63,7 +63,7 @@ class PageArchive { * @return ResultWrapper */ public static function listAllPages() { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); return self::listPages( $dbr, '' ); } @@ -77,7 +77,7 @@ class PageArchive { * @return ResultWrapper */ public static function listPagesByPrefix( $prefix ) { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $title = Title::newFromText( $prefix ); if ( $title ) { @@ -127,7 +127,7 @@ class PageArchive { * @return ResultWrapper */ function listRevisions() { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $tables = [ 'archive' ]; @@ -179,7 +179,7 @@ class PageArchive { return null; } - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); return $dbr->select( 'filearchive', ArchivedFile::selectFields(), @@ -197,7 +197,7 @@ class PageArchive { * @return Revision|null */ function getRevision( $timestamp ) { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $fields = [ 'ar_rev_id', @@ -244,7 +244,7 @@ class PageArchive { * @return Revision|null Null when there is no previous revision */ function getPreviousRevision( $timestamp ) { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); // Check the previous deleted revision... $row = $dbr->selectRow( 'archive', @@ -300,7 +300,7 @@ class PageArchive { } // New-style: keyed to the text storage backend. - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $text = $dbr->selectRow( 'text', [ 'old_text', 'old_flags' ], [ 'old_id' => $row->ar_text_id ], @@ -318,7 +318,7 @@ class PageArchive { * @return string|null */ function getLastRevisionText() { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $row = $dbr->selectRow( 'archive', [ 'ar_text', 'ar_flags', 'ar_text_id' ], [ 'ar_namespace' => $this->title->getNamespace(), @@ -339,7 +339,7 @@ class PageArchive { * @return bool */ function isDeleted() { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $n = $dbr->selectField( 'archive', 'COUNT(ar_title)', [ 'ar_namespace' => $this->title->getNamespace(), 'ar_title' => $this->title->getDBkey() ], @@ -1247,7 +1247,7 @@ class SpecialUndelete extends SpecialPage { $minor = $rev->isMinor() ? ChangesList::flag( 'minor' ) : ''; - $tags = wfGetDB( DB_SLAVE )->selectField( + $tags = wfGetDB( DB_REPLICA )->selectField( 'tag_summary', 'ts_tags', [ 'ts_rev_id' => $rev->getId() ], diff --git a/includes/specials/SpecialVersion.php b/includes/specials/SpecialVersion.php index 6f71a51e27..c8b85ae7a3 100644 --- a/includes/specials/SpecialVersion.php +++ b/includes/specials/SpecialVersion.php @@ -209,7 +209,7 @@ class SpecialVersion extends SpecialPage { * @return string */ public static function softwareInformation() { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); // Put the software in an array of form 'name' => 'version'. All messages should // be loaded here, so feel free to use wfMessage in the 'name'. Raw HTML or diff --git a/includes/specials/SpecialWatchlist.php b/includes/specials/SpecialWatchlist.php index 854ca658e6..99f9c7c029 100644 --- a/includes/specials/SpecialWatchlist.php +++ b/includes/specials/SpecialWatchlist.php @@ -313,7 +313,7 @@ class SpecialWatchlist extends ChangesListSpecialPage { * @return IDatabase */ protected function getDB() { - return wfGetDB( DB_SLAVE, 'watchlist' ); + return wfGetDB( DB_REPLICA, 'watchlist' ); } /** diff --git a/includes/specials/SpecialWhatlinkshere.php b/includes/specials/SpecialWhatlinkshere.php index baa55f098a..1ead290f2a 100644 --- a/includes/specials/SpecialWhatlinkshere.php +++ b/includes/specials/SpecialWhatlinkshere.php @@ -105,7 +105,7 @@ class SpecialWhatLinksHere extends IncludableSpecialPage { */ function showIndirectLinks( $level, $target, $limit, $from = 0, $back = 0 ) { $out = $this->getOutput(); - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $hidelinks = $this->opts->getValue( 'hidelinks' ); $hideredirs = $this->opts->getValue( 'hideredirs' ); diff --git a/includes/specials/SpecialWithoutinterwiki.php b/includes/specials/SpecialWithoutinterwiki.php index 259d1f959e..a1e5156397 100644 --- a/includes/specials/SpecialWithoutinterwiki.php +++ b/includes/specials/SpecialWithoutinterwiki.php @@ -97,7 +97,7 @@ class WithoutInterwikiPage extends PageQueryPage { 'join_conds' => [ 'langlinks' => [ 'LEFT JOIN', 'll_from = page_id' ] ] ]; if ( $this->prefix ) { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $query['conds'][] = 'page_title ' . $dbr->buildLike( $this->prefix, $dbr->anyString() ); } diff --git a/includes/specials/pagers/AllMessagesTablePager.php b/includes/specials/pagers/AllMessagesTablePager.php index ee8b3dae7d..5609310173 100644 --- a/includes/specials/pagers/AllMessagesTablePager.php +++ b/includes/specials/pagers/AllMessagesTablePager.php @@ -196,7 +196,7 @@ class AllMessagesTablePager extends TablePager { public static function getCustomisedStatuses( $messageNames, $langcode = 'en', $foreign = false ) { // FIXME: This function should be moved to Language:: or something. - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $res = $dbr->select( 'page', [ 'page_namespace', 'page_title' ], [ 'page_namespace' => [ NS_MEDIAWIKI, NS_MEDIAWIKI_TALK ] ], diff --git a/includes/specials/pagers/ContribsPager.php b/includes/specials/pagers/ContribsPager.php index 28895a0f32..bc0ebc2bd8 100644 --- a/includes/specials/pagers/ContribsPager.php +++ b/includes/specials/pagers/ContribsPager.php @@ -74,7 +74,7 @@ class ContribsPager extends ReverseChronologicalPager { // with extra user based indexes or partioning by user. The additional metadata // queries should use a regular replica DB since the lookup pattern is not all by user. $this->mDbSecondary = wfGetDB( DB_SLAVE ); // any random replica DB - $this->mDb = wfGetDB( DB_SLAVE, 'contributions' ); + $this->mDb = wfGetDB( DB_REPLICA, 'contributions' ); } function getDefaultQuery() { diff --git a/includes/specials/pagers/DeletedContribsPager.php b/includes/specials/pagers/DeletedContribsPager.php index f2421f871a..1acbba1070 100644 --- a/includes/specials/pagers/DeletedContribsPager.php +++ b/includes/specials/pagers/DeletedContribsPager.php @@ -43,7 +43,7 @@ class DeletedContribsPager extends IndexPager { } $this->target = $target; $this->namespace = $namespace; - $this->mDb = wfGetDB( DB_SLAVE, 'contributions' ); + $this->mDb = wfGetDB( DB_REPLICA, 'contributions' ); } function getDefaultQuery() { diff --git a/includes/specials/pagers/ImageListPager.php b/includes/specials/pagers/ImageListPager.php index 5e10269cad..7fc4a9595d 100644 --- a/includes/specials/pagers/ImageListPager.php +++ b/includes/specials/pagers/ImageListPager.php @@ -74,7 +74,7 @@ class ImageListPager extends TablePager { $nt = Title::newFromText( $this->mSearch ); if ( $nt ) { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $this->mQueryConds[] = 'LOWER(img_name)' . $dbr->buildLike( $dbr->anyString(), strtolower( $nt->getDBkey() ), $dbr->anyString() ); @@ -136,7 +136,7 @@ class ImageListPager extends TablePager { if ( $this->mSearch !== '' ) { $nt = Title::newFromText( $this->mSearch ); if ( $nt ) { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $conds[] = 'LOWER(' . $prefix . '_name)' . $dbr->buildLike( $dbr->anyString(), strtolower( $nt->getDBkey() ), $dbr->anyString() ); @@ -272,7 +272,7 @@ class ImageListPager extends TablePager { } unset( $field ); - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); if ( $dbr->implicitGroupby() ) { $options = [ 'GROUP BY' => 'img_name' ]; } else { diff --git a/includes/specials/pagers/MergeHistoryPager.php b/includes/specials/pagers/MergeHistoryPager.php index 0b9587c422..56229b3b76 100644 --- a/includes/specials/pagers/MergeHistoryPager.php +++ b/includes/specials/pagers/MergeHistoryPager.php @@ -36,7 +36,7 @@ class MergeHistoryPager extends ReverseChronologicalPager { $this->title = $source; $this->articleID = $source->getArticleID(); - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $maxtimestamp = $dbr->selectField( 'revision', 'MIN(rev_timestamp)', diff --git a/includes/specials/pagers/NewFilesPager.php b/includes/specials/pagers/NewFilesPager.php index d1f9f40720..41819fc431 100644 --- a/includes/specials/pagers/NewFilesPager.php +++ b/includes/specials/pagers/NewFilesPager.php @@ -91,7 +91,7 @@ class NewFilesPager extends ReverseChronologicalPager { $likeVal = $opts->getValue( 'like' ); if ( !$this->getConfig()->get( 'MiserMode' ) && $likeVal !== '' ) { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $likeObj = Title::newFromText( $likeVal ); if ( $likeObj instanceof Title ) { $like = $dbr->buildLike( diff --git a/includes/specials/pagers/UsersPager.php b/includes/specials/pagers/UsersPager.php index adc1dd8923..901be38993 100644 --- a/includes/specials/pagers/UsersPager.php +++ b/includes/specials/pagers/UsersPager.php @@ -100,7 +100,7 @@ class UsersPager extends AlphabeticPager { * @return array */ function getQueryInfo() { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $conds = []; // Don't show hidden names @@ -228,7 +228,7 @@ class UsersPager extends AlphabeticPager { } // Lookup groups for all the users - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $groupRes = $dbr->select( 'user_groups', [ 'ug_user', 'ug_group' ], diff --git a/includes/upload/UploadStash.php b/includes/upload/UploadStash.php index 1c3e13b985..5bcced8512 100644 --- a/includes/upload/UploadStash.php +++ b/includes/upload/UploadStash.php @@ -489,10 +489,10 @@ class UploadStash { * Helper function: do the actual database query to fetch file metadata. * * @param string $key - * @param int $readFromDB Constant (default: DB_SLAVE) + * @param int $readFromDB Constant (default: DB_REPLICA) * @return bool */ - protected function fetchFileMetadata( $key, $readFromDB = DB_SLAVE ) { + protected function fetchFileMetadata( $key, $readFromDB = DB_REPLICA ) { // populate $fileMetadata[$key] $dbr = null; if ( $readFromDB === DB_MASTER ) { diff --git a/includes/user/BotPassword.php b/includes/user/BotPassword.php index 49a71633c7..4ce3cde4ed 100644 --- a/includes/user/BotPassword.php +++ b/includes/user/BotPassword.php @@ -67,7 +67,7 @@ class BotPassword implements IDBAccessObject { /** * Get a database connection for the bot passwords database - * @param int $db Index of the connection to get, e.g. DB_MASTER or DB_SLAVE. + * @param int $db Index of the connection to get, e.g. DB_MASTER or DB_REPLICA. * @return DatabaseBase */ public static function getDB( $db ) { diff --git a/includes/user/LocalIdLookup.php b/includes/user/LocalIdLookup.php index f7c54089b8..0d8b1a8ede 100644 --- a/includes/user/LocalIdLookup.php +++ b/includes/user/LocalIdLookup.php @@ -60,7 +60,7 @@ class LocalIdLookup extends CentralIdLookup { } $audience = $this->checkAudience( $audience ); - $db = wfGetDB( ( $flags & self::READ_LATEST ) ? DB_MASTER : DB_SLAVE ); + $db = wfGetDB( ( $flags & self::READ_LATEST ) ? DB_MASTER : DB_REPLICA ); $options = ( ( $flags & self::READ_LOCKING ) == self::READ_LOCKING ) ? [ 'LOCK IN SHARE MODE' ] : []; @@ -93,7 +93,7 @@ class LocalIdLookup extends CentralIdLookup { } $audience = $this->checkAudience( $audience ); - $db = wfGetDB( ( $flags & self::READ_LATEST ) ? DB_MASTER : DB_SLAVE ); + $db = wfGetDB( ( $flags & self::READ_LATEST ) ? DB_MASTER : DB_REPLICA ); $options = ( ( $flags & self::READ_LOCKING ) == self::READ_LOCKING ) ? [ 'LOCK IN SHARE MODE' ] : []; diff --git a/includes/user/PasswordReset.php b/includes/user/PasswordReset.php index bc87cd03dd..889ec92b42 100644 --- a/includes/user/PasswordReset.php +++ b/includes/user/PasswordReset.php @@ -236,7 +236,7 @@ class PasswordReset { * @throws MWException On unexpected database errors */ protected function getUsersByEmail( $email ) { - $res = wfGetDB( DB_SLAVE )->select( + $res = wfGetDB( DB_REPLICA )->select( 'user', User::selectFields(), [ 'user_email' => $email ], diff --git a/includes/user/User.php b/includes/user/User.php index 8b92e020d4..971ef7019f 100644 --- a/includes/user/User.php +++ b/includes/user/User.php @@ -474,7 +474,7 @@ class User implements IDBAccessObject { $this->getCacheKey( $cache ), $cache::TTL_HOUR, function ( $oldValue, &$ttl, array &$setOpts ) use ( $cache ) { - $setOpts += Database::getCacheSetOptions( wfGetDB( DB_SLAVE ) ); + $setOpts += Database::getCacheSetOptions( wfGetDB( DB_REPLICA ) ); wfDebug( "User: cache miss for user {$this->mId}\n" ); $this->loadFromDatabase( self::READ_NORMAL ); @@ -566,7 +566,7 @@ class User implements IDBAccessObject { public static function newFromConfirmationCode( $code, $flags = 0 ) { $db = ( $flags & self::READ_LATEST ) == self::READ_LATEST ? wfGetDB( DB_MASTER ) - : wfGetDB( DB_SLAVE ); + : wfGetDB( DB_REPLICA ); $id = $db->selectField( 'user', @@ -897,7 +897,7 @@ class User implements IDBAccessObject { $conds[] = 'ug_user > ' . (int)$after; } - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $ids = $dbr->selectFieldValues( 'user_groups', 'ug_user', @@ -1362,7 +1362,7 @@ class User implements IDBAccessObject { if ( is_null( $this->mGroups ) ) { $db = ( $this->queryFlagsUsed & self::READ_LATEST ) ? wfGetDB( DB_MASTER ) - : wfGetDB( DB_SLAVE ); + : wfGetDB( DB_REPLICA ); $res = $db->select( 'user_groups', [ 'ug_group' ], [ 'ug_user' => $this->mId ], @@ -2190,7 +2190,7 @@ class User implements IDBAccessObject { return []; } $utp = $this->getTalkPage(); - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); // Get the "last viewed rev" timestamp from the oldest message notification $timestamp = $dbr->selectField( 'user_newtalk', 'MIN(user_last_timestamp)', @@ -2233,7 +2233,7 @@ class User implements IDBAccessObject { * @return bool True if the user has new messages */ protected function checkNewtalk( $field, $id ) { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $ok = $dbr->selectField( 'user_newtalk', $field, [ $field => $id ], __METHOD__ ); @@ -3243,7 +3243,7 @@ class User implements IDBAccessObject { if ( is_null( $this->mFormerGroups ) ) { $db = ( $this->queryFlagsUsed & self::READ_LATEST ) ? wfGetDB( DB_MASTER ) - : wfGetDB( DB_SLAVE ); + : wfGetDB( DB_REPLICA ); $res = $db->select( 'user_former_groups', [ 'ufg_group' ], [ 'ufg_user' => $this->mId ], @@ -3268,7 +3268,7 @@ class User implements IDBAccessObject { if ( $this->mEditCount === null ) { /* Populate the count, if it has not been populated yet */ - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); // check if the user_editcount field has been initialized $count = $dbr->selectField( 'user', 'user_editcount', @@ -3870,7 +3870,7 @@ class User implements IDBAccessObject { $db = ( ( $flags & self::READ_LATEST ) == self::READ_LATEST ) ? wfGetDB( DB_MASTER ) - : wfGetDB( DB_SLAVE ); + : wfGetDB( DB_REPLICA ); $options = ( ( $flags & self::READ_LOCKING ) == self::READ_LOCKING ) ? [ 'LOCK IN SHARE MODE' ] @@ -4510,7 +4510,7 @@ class User implements IDBAccessObject { if ( $this->getId() == 0 ) { return false; // anons } - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $time = $dbr->selectField( 'revision', 'rev_timestamp', [ 'rev_user' => $this->getId() ], __METHOD__, @@ -4915,14 +4915,14 @@ class User implements IDBAccessObject { // Lazy initialization check... if ( $dbw->affectedRows() == 0 ) { // Now here's a goddamn hack... - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); if ( $dbr !== $dbw ) { // If we actually have a replica DB server, the count is // at least one behind because the current transaction // has not been committed and replicated. $this->mEditCount = $this->initEditCount( 1 ); } else { - // But if DB_SLAVE is selecting the master, then the + // But if DB_REPLICA is selecting the master, then the // count we just read includes the revision that was // just added in the working transaction. $this->mEditCount = $this->initEditCount(); @@ -4930,7 +4930,7 @@ class User implements IDBAccessObject { } else { if ( $this->mEditCount === null ) { $this->getEditCount(); - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $this->mEditCount += ( $dbr !== $dbw ) ? 1 : 0; } else { $this->mEditCount++; @@ -4949,7 +4949,7 @@ class User implements IDBAccessObject { protected function initEditCount( $add = 0 ) { // Pull from a replica DB to be less cruel to servers // Accuracy isn't the point anyway here - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $count = (int)$dbr->selectField( 'revision', 'COUNT(rev_user)', @@ -5107,7 +5107,7 @@ class User implements IDBAccessObject { // Load from database $dbr = ( $this->queryFlagsUsed & self::READ_LATEST ) ? wfGetDB( DB_MASTER ) - : wfGetDB( DB_SLAVE ); + : wfGetDB( DB_REPLICA ); $res = $dbr->select( 'user_properties', diff --git a/includes/user/UserArray.php b/includes/user/UserArray.php index a4d43562af..dddc850bd0 100644 --- a/includes/user/UserArray.php +++ b/includes/user/UserArray.php @@ -46,7 +46,7 @@ abstract class UserArray implements Iterator { // Database::select() doesn't like empty arrays return new ArrayIterator( [] ); } - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $res = $dbr->select( 'user', User::selectFields(), @@ -67,7 +67,7 @@ abstract class UserArray implements Iterator { // Database::select() doesn't like empty arrays return new ArrayIterator( [] ); } - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $res = $dbr->select( 'user', User::selectFields(), diff --git a/includes/user/UserNamePrefixSearch.php b/includes/user/UserNamePrefixSearch.php index 4a27a135d5..b7d5058211 100644 --- a/includes/user/UserNamePrefixSearch.php +++ b/includes/user/UserNamePrefixSearch.php @@ -39,7 +39,7 @@ class UserNamePrefixSearch { public static function search( $audience, $search, $limit, $offset = 0 ) { $user = User::newFromName( $search ); - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $prefix = $user ? $user->getName() : ''; $tables = [ 'user' ]; $cond = [ 'user_name ' . $dbr->buildLike( $prefix, $dbr->anyString() ) ]; diff --git a/maintenance/Maintenance.php b/maintenance/Maintenance.php index 0b61738a5e..6aa14b8add 100644 --- a/maintenance/Maintenance.php +++ b/maintenance/Maintenance.php @@ -1227,7 +1227,7 @@ abstract class Maintenance { * If not set, wfGetDB() will be used. * This function has the same parameters as wfGetDB() * - * @param integer $db DB index (DB_SLAVE/DB_MASTER) + * @param integer $db DB index (DB_REPLICA/DB_MASTER) * @param array $groups; default: empty array * @param string|bool $wiki; default: current wiki * @return IDatabase diff --git a/maintenance/backup.inc b/maintenance/backup.inc index db3af9263c..38daf646fd 100644 --- a/maintenance/backup.inc +++ b/maintenance/backup.inc @@ -302,7 +302,7 @@ class BackupDumper extends Maintenance { $dbr = $this->forcedDb; if ( $this->forcedDb === null ) { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); } $this->maxCount = $dbr->selectField( $table, "MAX($field)", '', __METHOD__ ); $this->startTime = microtime( true ); @@ -322,7 +322,7 @@ class BackupDumper extends Maintenance { } $this->lb = wfGetLBFactory()->newMainLB(); - $db = $this->lb->getConnection( DB_SLAVE, 'dump' ); + $db = $this->lb->getConnection( DB_REPLICA, 'dump' ); // Discourage the server from disconnecting us if it takes a long time // to read out the big ol' batch query. diff --git a/maintenance/benchmarks/benchmarkParse.php b/maintenance/benchmarks/benchmarkParse.php index 0a89bfa558..884e307f68 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 = $this->getDB( DB_SLAVE ); + $dbr = $this->getDB( DB_REPLICA ); $id = $dbr->selectField( [ 'revision', 'page' ], diff --git a/maintenance/checkBadRedirects.php b/maintenance/checkBadRedirects.php index 097ad1f588..6eafc96ec5 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 = $this->getDB( DB_SLAVE ); + $dbr = $this->getDB( DB_REPLICA ); $result = $dbr->select( [ 'page' ], [ 'page_namespace', 'page_title', 'page_latest' ], diff --git a/maintenance/checkImages.php b/maintenance/checkImages.php index f05d15c0af..3e57393096 100644 --- a/maintenance/checkImages.php +++ b/maintenance/checkImages.php @@ -37,7 +37,7 @@ class CheckImages extends Maintenance { public function execute() { $start = ''; - $dbr = $this->getDB( DB_SLAVE ); + $dbr = $this->getDB( DB_REPLICA ); $numImages = 0; $numGood = 0; diff --git a/maintenance/checkUsernames.php b/maintenance/checkUsernames.php index 6c66da4f39..e6d95477c3 100644 --- a/maintenance/checkUsernames.php +++ b/maintenance/checkUsernames.php @@ -40,7 +40,7 @@ class CheckUsernames extends Maintenance { } function execute() { - $dbr = $this->getDB( DB_SLAVE ); + $dbr = $this->getDB( DB_REPLICA ); $maxUserId = 0; do { diff --git a/maintenance/cleanupSpam.php b/maintenance/cleanupSpam.php index 2f3f01347c..4e47cfba57 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 = $this->getDB( DB_SLAVE, [], $wikiID ); + $dbr = $this->getDB( DB_REPLICA, [], $wikiID ); $count = $dbr->selectField( 'externallinks', 'COUNT(*)', [ 'el_index' . $dbr->buildLike( $like ) ], __METHOD__ ); @@ -83,7 +83,7 @@ class CleanupSpam extends Maintenance { } else { // Clean up spam on this wiki - $dbr = $this->getDB( DB_SLAVE ); + $dbr = $this->getDB( DB_REPLICA ); $res = $dbr->select( 'externallinks', [ 'DISTINCT el_from' ], [ 'el_index' . $dbr->buildLike( $like ) ], __METHOD__ ); $count = $dbr->numRows( $res ); diff --git a/maintenance/cleanupTable.inc b/maintenance/cleanupTable.inc index a18b81e7d9..3ace09cb30 100644 --- a/maintenance/cleanupTable.inc +++ b/maintenance/cleanupTable.inc @@ -106,7 +106,7 @@ class TableCleanup extends Maintenance { * @throws MWException */ public function runTable( $params ) { - $dbr = $this->getDB( DB_SLAVE ); + $dbr = $this->getDB( DB_REPLICA ); if ( array_diff( array_keys( $params ), [ 'table', 'conds', 'index', 'callback' ] ) diff --git a/maintenance/cleanupTitles.php b/maintenance/cleanupTitles.php index 4f23ef01af..650fae085a 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 = $this->getDB( DB_SLAVE ); + $dbr = $this->getDB( DB_REPLICA ); $row = $dbr->selectRow( 'image', [ 'img_name' ], [ 'img_name' => $name ], __METHOD__ ); return $row !== false; diff --git a/maintenance/clearInterwikiCache.php b/maintenance/clearInterwikiCache.php index 13b239fd84..ce19974e31 100644 --- a/maintenance/clearInterwikiCache.php +++ b/maintenance/clearInterwikiCache.php @@ -37,7 +37,7 @@ class ClearInterwikiCache extends Maintenance { public function execute() { global $wgLocalDatabases, $wgMemc; - $dbr = $this->getDB( DB_SLAVE ); + $dbr = $this->getDB( DB_REPLICA ); $res = $dbr->select( 'interwiki', [ 'iw_prefix' ], false ); $prefixes = []; foreach ( $res as $row ) { diff --git a/maintenance/compareParserCache.php b/maintenance/compareParserCache.php index 245b6131a6..8bd060f324 100644 --- a/maintenance/compareParserCache.php +++ b/maintenance/compareParserCache.php @@ -35,7 +35,7 @@ class CompareParserCache extends Maintenance { public function execute() { $pages = $this->getOption( 'maxpages' ); - $dbr = $this->getDB( DB_SLAVE ); + $dbr = $this->getDB( DB_REPLICA ); $totalsec = 0.0; $scanned = 0; diff --git a/maintenance/deleteDefaultMessages.php b/maintenance/deleteDefaultMessages.php index 35a7ca784f..69f4f893fc 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 = $this->getDB( DB_SLAVE ); + $dbr = $this->getDB( DB_REPLICA ); $res = $dbr->select( [ 'page', 'revision' ], [ 'page_namespace', 'page_title' ], [ diff --git a/maintenance/dumpLinks.php b/maintenance/dumpLinks.php index 1faeb8ae19..ff4e894502 100644 --- a/maintenance/dumpLinks.php +++ b/maintenance/dumpLinks.php @@ -44,7 +44,7 @@ class DumpLinks extends Maintenance { } public function execute() { - $dbr = $this->getDB( DB_SLAVE ); + $dbr = $this->getDB( DB_REPLICA ); $result = $dbr->select( [ 'pagelinks', 'page' ], [ 'page_id', diff --git a/maintenance/dumpTextPass.php b/maintenance/dumpTextPass.php index cfb59c6004..d0bda4ed3a 100644 --- a/maintenance/dumpTextPass.php +++ b/maintenance/dumpTextPass.php @@ -222,7 +222,7 @@ TEXT // 2. The Connection, through the load balancer. try { - $this->db = $this->lb->getConnection( DB_SLAVE, 'dump' ); + $this->db = $this->lb->getConnection( DB_REPLICA, 'dump' ); } catch ( Exception $e ) { throw new MWException( __METHOD__ . " rotating DB failed to obtain new database (" . $e->getMessage() . ")" ); diff --git a/maintenance/dumpUploads.php b/maintenance/dumpUploads.php index 5b446d8347..8d63fe55f9 100644 --- a/maintenance/dumpUploads.php +++ b/maintenance/dumpUploads.php @@ -76,7 +76,7 @@ By default, outputs relative paths against the parent directory of $wgUploadDire * @param bool $shared True to pass shared-dir settings to hash func */ function fetchUsed( $shared ) { - $dbr = $this->getDB( DB_SLAVE ); + $dbr = $this->getDB( DB_REPLICA ); $image = $dbr->tableName( 'image' ); $imagelinks = $dbr->tableName( 'imagelinks' ); @@ -97,7 +97,7 @@ By default, outputs relative paths against the parent directory of $wgUploadDire * @param bool $shared True to pass shared-dir settings to hash func */ function fetchLocal( $shared ) { - $dbr = $this->getDB( DB_SLAVE ); + $dbr = $this->getDB( DB_REPLICA ); $result = $dbr->select( 'image', [ 'img_name' ], '', diff --git a/maintenance/fetchText.php b/maintenance/fetchText.php index 7e1b527def..2ed1efaed5 100644 --- a/maintenance/fetchText.php +++ b/maintenance/fetchText.php @@ -49,7 +49,7 @@ class FetchText extends Maintenance { * note that the text string itself is *not* followed by newline */ public function execute() { - $db = $this->getDB( DB_SLAVE ); + $db = $this->getDB( DB_REPLICA ); $stdin = $this->getStdin(); while ( !feof( $stdin ) ) { $line = fgets( $stdin ); diff --git a/maintenance/fixDefaultJsonContentPages.php b/maintenance/fixDefaultJsonContentPages.php index 232151b878..460b553455 100644 --- a/maintenance/fixDefaultJsonContentPages.php +++ b/maintenance/fixDefaultJsonContentPages.php @@ -47,7 +47,7 @@ class FixDefaultJsonContentPages extends LoggedUpdateMaintenance { return true; } - $dbr = $this->getDB( DB_SLAVE ); + $dbr = $this->getDB( DB_REPLICA ); $namespaces = [ NS_MEDIAWIKI => $dbr->buildLike( $dbr->anyString(), '.json' ), NS_USER => $dbr->buildLike( $dbr->anyString(), '/', $dbr->anyString(), '.json' ), diff --git a/maintenance/fixDoubleRedirects.php b/maintenance/fixDoubleRedirects.php index 0592d2da51..1d6f31de08 100644 --- a/maintenance/fixDoubleRedirects.php +++ b/maintenance/fixDoubleRedirects.php @@ -54,7 +54,7 @@ class FixDoubleRedirects extends Maintenance { $title = null; } - $dbr = $this->getDB( DB_SLAVE ); + $dbr = $this->getDB( DB_REPLICA ); // See also SpecialDoubleRedirects $tables = [ diff --git a/maintenance/generateSitemap.php b/maintenance/generateSitemap.php index ff7ed457ac..87af5b83cc 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 = $this->getDB( DB_SLAVE ); + $this->dbr = $this->getDB( DB_REPLICA ); $this->generateNamespaces(); $this->timestamp = wfTimestamp( TS_ISO_8601, wfTimestampNow() ); $this->findex = fopen( "{$this->fspath}sitemap-index-{$this->identifier}.xml", 'wb' ); diff --git a/maintenance/getReplicaServer.php b/maintenance/getReplicaServer.php index b3e7377372..6e0a1fec2d 100644 --- a/maintenance/getReplicaServer.php +++ b/maintenance/getReplicaServer.php @@ -40,7 +40,7 @@ class GetSlaveServer extends Maintenance { if ( $wgAllDBsAreLocalhost ) { $host = 'localhost'; } elseif ( $this->hasOption( 'group' ) ) { - $db = $this->getDB( DB_SLAVE, $this->getOption( 'group' ) ); + $db = $this->getDB( DB_REPLICA, $this->getOption( 'group' ) ); $host = $db->getServer(); } else { $lb = wfGetLB(); diff --git a/maintenance/initEditCount.php b/maintenance/initEditCount.php index a19ad9b2cf..6b06da781e 100644 --- a/maintenance/initEditCount.php +++ b/maintenance/initEditCount.php @@ -56,7 +56,7 @@ in the load balancer, usually indicating a replication environment.' ); if ( $backgroundMode ) { $this->output( "Using replication-friendly background mode...\n" ); - $dbr = $this->getDB( DB_SLAVE ); + $dbr = $this->getDB( DB_REPLICA ); $chunkSize = 100; $lastUser = $dbr->selectField( 'user', 'MAX(user_id)', '', __METHOD__ ); diff --git a/maintenance/populateRevisionLength.php b/maintenance/populateRevisionLength.php index dcb9933e5b..5e44fafd9f 100644 --- a/maintenance/populateRevisionLength.php +++ b/maintenance/populateRevisionLength.php @@ -73,7 +73,7 @@ class PopulateRevisionLength extends LoggedUpdateMaintenance { * @return int */ protected function doLenUpdates( $table, $idCol, $prefix, $fields ) { - $dbr = $this->getDB( DB_SLAVE ); + $dbr = $this->getDB( DB_REPLICA ); $dbw = $this->getDB( DB_MASTER ); $start = $dbw->selectField( $table, "MIN($idCol)", false, __METHOD__ ); $end = $dbw->selectField( $table, "MAX($idCol)", false, __METHOD__ ); diff --git a/maintenance/purgeChangedFiles.php b/maintenance/purgeChangedFiles.php index 70a26cbdf6..615d1fe9a2 100644 --- a/maintenance/purgeChangedFiles.php +++ b/maintenance/purgeChangedFiles.php @@ -106,7 +106,7 @@ class PurgeChangedFiles extends Maintenance { } // Validate the timestamps - $dbr = $this->getDB( DB_SLAVE ); + $dbr = $this->getDB( DB_REPLICA ); $this->startTimestamp = $dbr->timestamp( $this->getOption( 'starttime' ) ); $this->endTimestamp = $dbr->timestamp( $this->getOption( 'endtime' ) ); @@ -137,7 +137,7 @@ class PurgeChangedFiles extends Maintenance { */ protected function purgeFromLogType( $type ) { $repo = RepoGroup::singleton()->getLocalRepo(); - $dbr = $this->getDB( DB_SLAVE ); + $dbr = $this->getDB( DB_REPLICA ); foreach ( self::$typeMappings[$type] as $logType => $logActions ) { $this->verbose( "Scanning for {$logType}/" . implode( ',', $logActions ) . "\n" ); diff --git a/maintenance/purgeChangedPages.php b/maintenance/purgeChangedPages.php index 58a46400bf..b354399f88 100644 --- a/maintenance/purgeChangedPages.php +++ b/maintenance/purgeChangedPages.php @@ -65,7 +65,7 @@ class PurgeChangedPages extends Maintenance { } } - $dbr = $this->getDB( DB_SLAVE ); + $dbr = $this->getDB( DB_REPLICA ); $minTime = $dbr->timestamp( $this->getOption( 'starttime' ) ); $maxTime = $dbr->timestamp( $this->getOption( 'endtime' ) ); diff --git a/maintenance/purgeList.php b/maintenance/purgeList.php index 21d116963d..5ca7918ea9 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 = $this->getDB( DB_SLAVE ); + $dbr = $this->getDB( DB_REPLICA ); $startId = 0; if ( $namespace === false ) { $conds = []; diff --git a/maintenance/rebuildFileCache.php b/maintenance/rebuildFileCache.php index 38556ede3e..649557ed28 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 = $this->getDB( DB_SLAVE ); + $dbr = $this->getDB( DB_REPLICA ); $overwrite = $this->getOption( 'overwrite', false ); $start = ( $start > 0 ) ? $start diff --git a/maintenance/rebuildImages.php b/maintenance/rebuildImages.php index f67739bae1..31571866c7 100644 --- a/maintenance/rebuildImages.php +++ b/maintenance/rebuildImages.php @@ -127,7 +127,7 @@ class ImageBuilder extends Maintenance { $this->init( $count, $table ); $this->output( "Processing $table...\n" ); - $result = $this->getDB( DB_SLAVE )->select( $table, '*', [], __METHOD__ ); + $result = $this->getDB( DB_REPLICA )->select( $table, '*', [], __METHOD__ ); foreach ( $result as $row ) { $update = call_user_func( $callback, $row, null ); diff --git a/maintenance/rebuildall.php b/maintenance/rebuildall.php index d2ee6fc2ad..95822ca269 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 ( $this->getDB( DB_SLAVE )->getType() != 'postgres' ) { + if ( $this->getDB( DB_REPLICA )->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/refreshFileHeaders.php b/maintenance/refreshFileHeaders.php index ea5b6f9757..e075501518 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 = $this->getDB( DB_SLAVE ); + $dbr = $this->getDB( DB_REPLICA ); do { $conds = [ "img_name > {$dbr->addQuotes( $start )}" ]; if ( strlen( $end ) ) { diff --git a/maintenance/refreshLinks.php b/maintenance/refreshLinks.php index 95a49d6c2a..24c8c11148 100644 --- a/maintenance/refreshLinks.php +++ b/maintenance/refreshLinks.php @@ -74,7 +74,7 @@ class RefreshLinks extends Maintenance { $end = null, $redirectsOnly = false, $oldRedirectsOnly = false ) { $reportingInterval = 100; - $dbr = $this->getDB( DB_SLAVE ); + $dbr = $this->getDB( DB_REPLICA ); if ( $start === null ) { $start = 1; @@ -258,7 +258,7 @@ class RefreshLinks extends Maintenance { ) { wfWaitForSlaves(); $this->output( "Deleting illegal entries from the links tables...\n" ); - $dbr = $this->getDB( DB_SLAVE ); + $dbr = $this->getDB( DB_REPLICA ); do { // Find the start of the next chunk. This is based only // on existent page_ids. @@ -299,7 +299,7 @@ class RefreshLinks extends Maintenance { */ private function dfnCheckInterval( $start = null, $end = null, $batchSize = 100 ) { $dbw = $this->getDB( DB_MASTER ); - $dbr = $this->getDB( DB_SLAVE ); + $dbr = $this->getDB( DB_REPLICA ); $linksTables = [ // table name => page_id field 'pagelinks' => 'pl_from', diff --git a/maintenance/removeInvalidEmails.php b/maintenance/removeInvalidEmails.php index 0f67317dfb..1034005aa0 100644 --- a/maintenance/removeInvalidEmails.php +++ b/maintenance/removeInvalidEmails.php @@ -23,7 +23,7 @@ class RemoveInvalidEmails extends Maintenance { } public function execute() { $this->commit = $this->hasOption( 'commit' ); - $dbr = $this->getDB( DB_SLAVE ); + $dbr = $this->getDB( DB_REPLICA ); $dbw = $this->getDB( DB_MASTER ); $lastId = 0; do { diff --git a/maintenance/removeUnusedAccounts.php b/maintenance/removeUnusedAccounts.php index e3c99ed5c9..ec8fcfe1ae 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 = []; - $dbr = $this->getDB( DB_SLAVE ); + $dbr = $this->getDB( DB_REPLICA ); $res = $dbr->select( 'user', [ 'user_id', 'user_name', 'user_touched' ], '', __METHOD__ ); if ( $this->hasOption( 'ignore-groups' ) ) { $excludedGroups = explode( ',', $this->getOption( 'ignore-groups' ) ); @@ -107,7 +107,7 @@ class RemoveUnusedAccounts extends Maintenance { * @return bool */ private function isInactiveAccount( $id, $master = false ) { - $dbo = $this->getDB( $master ? DB_MASTER : DB_SLAVE ); + $dbo = $this->getDB( $master ? DB_MASTER : DB_REPLICA ); $checks = [ 'revision' => 'rev', 'archive' => 'ar', diff --git a/maintenance/resetUserTokens.php b/maintenance/resetUserTokens.php index df3f6d765d..481da980da 100644 --- a/maintenance/resetUserTokens.php +++ b/maintenance/resetUserTokens.php @@ -68,7 +68,8 @@ class ResetUserTokens extends Maintenance { } // We list user by user_id from one of the replica DBs - $dbr = $this->getDB( DB_SLAVE ); + // We list user by user_id from one of the slave database + $dbr = $this->getDB( DB_REPLICA ); $where = []; if ( $this->nullsOnly ) { diff --git a/maintenance/rollbackEdits.php b/maintenance/rollbackEdits.php index 10c107e674..5ad7d4e1c4 100644 --- a/maintenance/rollbackEdits.php +++ b/maintenance/rollbackEdits.php @@ -95,7 +95,7 @@ class RollbackEdits extends Maintenance { * @return array */ private function getRollbackTitles( $user ) { - $dbr = $this->getDB( DB_SLAVE ); + $dbr = $this->getDB( DB_REPLICA ); $titles = []; $results = $dbr->select( [ 'page', 'revision' ], diff --git a/maintenance/showSiteStats.php b/maintenance/showSiteStats.php index 205dfdd6ee..5a151651d6 100644 --- a/maintenance/showSiteStats.php +++ b/maintenance/showSiteStats.php @@ -53,7 +53,7 @@ class ShowSiteStats extends Maintenance { ]; // Get cached stats from a replica DB - $dbr = $this->getDB( DB_SLAVE ); + $dbr = $this->getDB( DB_REPLICA ); $stats = $dbr->selectRow( 'site_stats', '*', '', __METHOD__ ); // Get maximum size for each column diff --git a/maintenance/sql.php b/maintenance/sql.php index bf50f6598a..60e6956095 100644 --- a/maintenance/sql.php +++ b/maintenance/sql.php @@ -55,7 +55,7 @@ class MwSql extends Maintenance { // Figure out which server to use $replicaDB = $this->getOption( 'replicadb', $this->getOption( 'slave', '' ) ); if ( $replicaDB === 'any' ) { - $index = DB_SLAVE; + $index = DB_REPLICA; } elseif ( $replicaDB != '' ) { $index = null; $serverCount = $lb->getServerCount(); diff --git a/maintenance/storage/checkStorage.php b/maintenance/storage/checkStorage.php index d69e5b9413..bb9f4eacc5 100644 --- a/maintenance/storage/checkStorage.php +++ b/maintenance/storage/checkStorage.php @@ -57,7 +57,7 @@ class CheckStorage { ]; function check( $fix = false, $xml = '' ) { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); if ( $fix ) { print "Checking, will fix errors if possible...\n"; } else { @@ -462,7 +462,7 @@ class CheckStorage { return; } - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $dbw = wfGetDB( DB_MASTER ); $dbr->ping(); $dbw->ping(); @@ -507,7 +507,7 @@ class CheckStorage { } // Find text row again - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $oldId = $dbr->selectField( 'revision', 'rev_text_id', [ 'rev_id' => $id ], __METHOD__ ); if ( !$oldId ) { echo "Missing revision row for rev_id $id\n"; diff --git a/maintenance/storage/compressOld.php b/maintenance/storage/compressOld.php index ba924bf7af..289d22d9a9 100644 --- a/maintenance/storage/compressOld.php +++ b/maintenance/storage/compressOld.php @@ -237,7 +237,7 @@ class CompressOld extends Maintenance { ) { $loadStyle = self::LS_CHUNKED; - $dbr = $this->getDB( DB_SLAVE ); + $dbr = $this->getDB( DB_REPLICA ); $dbw = $this->getDB( DB_MASTER ); # Set up external storage diff --git a/maintenance/storage/dumpRev.php b/maintenance/storage/dumpRev.php index 39e06a3a61..437bfcdefc 100644 --- a/maintenance/storage/dumpRev.php +++ b/maintenance/storage/dumpRev.php @@ -36,7 +36,7 @@ class DumpRev extends Maintenance { } public function execute() { - $dbr = $this->getDB( DB_SLAVE ); + $dbr = $this->getDB( DB_REPLICA ); $row = $dbr->selectRow( [ 'text', 'revision' ], [ 'old_flags', 'old_text' ], diff --git a/maintenance/storage/fixBug20757.php b/maintenance/storage/fixBug20757.php index 94335cfd4d..b444f31143 100644 --- a/maintenance/storage/fixBug20757.php +++ b/maintenance/storage/fixBug20757.php @@ -42,7 +42,7 @@ class FixBug20757 extends Maintenance { } function execute() { - $dbr = $this->getDB( DB_SLAVE ); + $dbr = $this->getDB( DB_REPLICA ); $dbw = $this->getDB( DB_MASTER ); $dryRun = $this->getOption( 'dry-run' ); @@ -281,7 +281,7 @@ class FixBug20757 extends Maintenance { unset( $this->mapCache[$key] ); } - $dbr = $this->getDB( DB_SLAVE ); + $dbr = $this->getDB( DB_REPLICA ); $map = []; $res = $dbr->select( 'revision', [ 'rev_id', 'rev_text_id' ], diff --git a/maintenance/storage/moveToExternal.php b/maintenance/storage/moveToExternal.php index 80dc7f9620..e1179920ca 100644 --- a/maintenance/storage/moveToExternal.php +++ b/maintenance/storage/moveToExternal.php @@ -51,7 +51,7 @@ if ( !defined( 'MEDIAWIKI' ) ) { function moveToExternal( $cluster, $maxID, $minID = 1 ) { $fname = 'moveToExternal'; $dbw = wfGetDB( DB_MASTER ); - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $count = $maxID - $minID + 1; $blockSize = 1000; diff --git a/maintenance/storage/orphanStats.php b/maintenance/storage/orphanStats.php index d775830df2..d7d0b84c5f 100644 --- a/maintenance/storage/orphanStats.php +++ b/maintenance/storage/orphanStats.php @@ -39,11 +39,11 @@ class OrphanStats extends Maintenance { protected function &getDB( $cluster, $groups = [], $wiki = false ) { $lb = wfGetLBFactory()->getExternalLB( $cluster ); - return $lb->getConnection( DB_SLAVE ); + return $lb->getConnection( DB_REPLICA ); } public function execute() { - $dbr = $this->getDB( DB_SLAVE ); + $dbr = $this->getDB( DB_REPLICA ); 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/recompressTracked.php b/maintenance/storage/recompressTracked.php index 8f717dec46..0a62103ca7 100644 --- a/maintenance/storage/recompressTracked.php +++ b/maintenance/storage/recompressTracked.php @@ -154,7 +154,7 @@ class RecompressTracked { */ function syncDBs() { $dbw = wfGetDB( DB_MASTER ); - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $pos = $dbw->getMasterPos(); $dbr->masterPosWait( $pos, 100000 ); } @@ -190,7 +190,7 @@ class RecompressTracked { * @return bool */ function checkTrackingTable() { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); if ( !$dbr->tableExists( 'blob_tracking' ) ) { $this->critical( "Error: blob_tracking table does not exist" ); @@ -305,7 +305,7 @@ class RecompressTracked { * Move all tracked pages to the new clusters */ function doAllPages() { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $i = 0; $startId = 0; if ( $this->noCount ) { @@ -374,7 +374,7 @@ class RecompressTracked { * Move all orphan text to the new clusters */ function doAllOrphans() { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $startId = 0; $i = 0; if ( $this->noCount ) { @@ -480,7 +480,7 @@ class RecompressTracked { } else { $titleText = '[deleted]'; } - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); // Finish any incomplete transactions if ( !$this->copyOnly ) { @@ -590,7 +590,7 @@ class RecompressTracked { * @param array $conds */ function finishIncompleteMoves( $conds ) { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $startId = 0; $conds = array_merge( $conds, [ @@ -659,7 +659,7 @@ class RecompressTracked { $trx = new CgzCopyTransaction( $this, $this->orphanBlobClass ); - $res = wfGetDB( DB_SLAVE )->select( + $res = wfGetDB( DB_REPLICA )->select( [ 'text', 'blob_tracking' ], [ 'old_id', 'old_text', 'old_flags' ], [ diff --git a/maintenance/storage/resolveStubs.php b/maintenance/storage/resolveStubs.php index 33a9f965ac..8ca8bb291b 100644 --- a/maintenance/storage/resolveStubs.php +++ b/maintenance/storage/resolveStubs.php @@ -37,7 +37,7 @@ if ( !defined( 'MEDIAWIKI' ) ) { function resolveStubs() { $fname = 'resolveStubs'; - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $maxID = $dbr->selectField( 'text', 'MAX(old_id)', false, $fname ); $blockSize = 10000; $numBlocks = intval( $maxID / $blockSize ) + 1; @@ -73,7 +73,7 @@ function resolveStub( $id, $stubText, $flags ) { $stub = unserialize( $stubText ); $flags = explode( ',', $flags ); - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $dbw = wfGetDB( DB_MASTER ); if ( strtolower( get_class( $stub ) ) !== 'historyblobstub' ) { diff --git a/maintenance/storage/storageTypeStats.php b/maintenance/storage/storageTypeStats.php index 04d2557e67..c23f50866a 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 = $this->getDB( DB_SLAVE ); + $dbr = $this->getDB( DB_REPLICA ); $endId = $dbr->selectField( 'text', 'MAX(old_id)', false, __METHOD__ ); if ( !$endId ) { diff --git a/maintenance/storage/testCompression.php b/maintenance/storage/testCompression.php index 2692a07a84..90d8d03110 100644 --- a/maintenance/storage/testCompression.php +++ b/maintenance/storage/testCompression.php @@ -47,7 +47,7 @@ if ( isset( $options['limit'] ) ) { } $type = isset( $options['type'] ) ? $options['type'] : 'ConcatenatedGzipHistoryBlob'; -$dbr = $this->getDB( DB_SLAVE ); +$dbr = $this->getDB( DB_REPLICA ); $res = $dbr->select( [ 'page', 'revision', 'text' ], '*', diff --git a/maintenance/storage/trackBlobs.php b/maintenance/storage/trackBlobs.php index 9da4699a25..a2dc376800 100644 --- a/maintenance/storage/trackBlobs.php +++ b/maintenance/storage/trackBlobs.php @@ -67,7 +67,7 @@ class TrackBlobs { function checkIntegrity() { echo "Doing integrity check...\n"; - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); // Scan for HistoryBlobStub objects in the text table (bug 20757) @@ -117,7 +117,7 @@ class TrackBlobs { function getTextClause() { if ( !$this->textClause ) { - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $this->textClause = ''; foreach ( $this->clusters as $cluster ) { if ( $this->textClause != '' ) { @@ -147,7 +147,7 @@ class TrackBlobs { */ function trackRevisions() { $dbw = wfGetDB( DB_MASTER ); - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $textClause = $this->getTextClause(); $startId = 0; @@ -221,7 +221,7 @@ class TrackBlobs { function trackOrphanText() { # Wait until the blob_tracking table is available in the replica DB $dbw = wfGetDB( DB_MASTER ); - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $pos = $dbw->getMasterPos(); $dbr->masterPosWait( $pos, 100000 ); @@ -317,7 +317,7 @@ class TrackBlobs { echo "Searching for orphan blobs in $cluster...\n"; $lb = wfGetLBFactory()->getExternalLB( $cluster ); try { - $extDB = $lb->getConnection( DB_SLAVE ); + $extDB = $lb->getConnection( DB_REPLICA ); } catch ( DBConnectionError $e ) { if ( strpos( $e->error, 'Unknown database' ) !== false ) { echo "No database on $cluster\n"; diff --git a/maintenance/tidyUpBug37714.php b/maintenance/tidyUpBug37714.php index f47e13c06d..9d7cc0e9c3 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 = $this->getDB( DB_SLAVE )->select( + $result = $this->getDB( DB_REPLICA )->select( 'logging', [ 'log_id', 'log_params' ], [ @@ -21,7 +21,7 @@ class TidyUpBug37714 extends Maintenance { foreach ( $result as $row ) { $ids = explode( ',', explode( "\n", $row->log_params )[0] ); - $result = $this->getDB( DB_SLAVE )->select( // Work out what log entries were changed here. + $result = $this->getDB( DB_REPLICA )->select( // Work out what log entries were changed here. 'logging', 'log_type', [ 'log_id' => $ids ], diff --git a/maintenance/updateArticleCount.php b/maintenance/updateArticleCount.php index dff5aec8e4..213195df0f 100644 --- a/maintenance/updateArticleCount.php +++ b/maintenance/updateArticleCount.php @@ -46,7 +46,7 @@ class UpdateArticleCount extends Maintenance { if ( $this->hasOption( 'use-master' ) ) { $dbr = $this->getDB( DB_MASTER ); } else { - $dbr = $this->getDB( DB_SLAVE, 'vslow' ); + $dbr = $this->getDB( DB_REPLICA, 'vslow' ); } $counter = new SiteStatsInit( $dbr ); $result = $counter->articles(); diff --git a/maintenance/updateCollation.php b/maintenance/updateCollation.php index 46241ec9a4..e754e3c3ab 100644 --- a/maintenance/updateCollation.php +++ b/maintenance/updateCollation.php @@ -70,7 +70,7 @@ TEXT global $wgCategoryCollation; $dbw = $this->getDB( DB_MASTER ); - $dbr = $this->getDB( DB_SLAVE ); + $dbr = $this->getDB( DB_REPLICA ); $force = $this->getOption( 'force' ); $dryRun = $this->getOption( 'dry-run' ); $verboseStats = $this->getOption( 'verbose-stats' ); diff --git a/maintenance/userOptions.inc b/maintenance/userOptions.inc index a09d7ba76f..c657c03f7b 100644 --- a/maintenance/userOptions.inc +++ b/maintenance/userOptions.inc @@ -141,7 +141,7 @@ class UserOptions { $defaultOptions = User::getDefaultOptions(); // We list user by user_id from one of the replica DBs - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $result = $dbr->select( 'user', [ 'user_id' ], [], @@ -195,7 +195,7 @@ class UserOptions { $this->warn(); // We list user by user_id from one of the replica DBs - $dbr = wfGetDB( DB_SLAVE ); + $dbr = wfGetDB( DB_REPLICA ); $result = $dbr->select( 'user', [ 'user_id' ], [], -- 2.20.1