Merge "Turn off duplicate key gets for ReplicatedBagOStuff"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 6 Sep 2016 18:18:07 +0000 (18:18 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 6 Sep 2016 18:18:07 +0000 (18:18 +0000)
198 files changed:
autoload.php
docs/uidesign/mediawiki.action.history.diff.html [deleted file]
docs/uidesign/mediawiki.diff.html [new file with mode: 0644]
includes/Block.php
includes/Category.php
includes/CategoryFinder.php
includes/CategoryViewer.php
includes/DefaultSettings.php
includes/Defines.php
includes/EditPage.php
includes/GlobalFunctions.php
includes/HistoryBlob.php
includes/LinkFilter.php
includes/Linker.php
includes/MediaWiki.php
includes/MergeHistory.php
includes/OutputPage.php
includes/PageProps.php
includes/Pingback.php
includes/PrefixSearch.php
includes/Revision.php
includes/RevisionList.php
includes/SiteStats.php
includes/Title.php
includes/WatchedItemQueryService.php
includes/WatchedItemStore.php
includes/actions/HistoryAction.php
includes/actions/InfoAction.php
includes/api/ApiBase.php
includes/api/ApiMain.php
includes/api/ApiQueryUserContributions.php
includes/api/ApiQueryWatchlist.php
includes/api/ApiStashEdit.php
includes/api/ApiTag.php
includes/auth/AuthManager.php
includes/auth/TemporaryPasswordPrimaryAuthenticationProvider.php
includes/cache/BacklinkCache.php
includes/cache/GenderCache.php
includes/cache/LinkBatch.php
includes/cache/LinkCache.php
includes/cache/MessageBlobStore.php
includes/cache/MessageCache.php
includes/cache/UserCache.php
includes/cache/localisation/LCStoreDB.php
includes/changes/CategoryMembershipChange.php
includes/changes/RecentChange.php
includes/changetags/ChangeTags.php
includes/content/ContentHandler.php
includes/dao/DBAccessObjectUtils.php
includes/dao/IDBAccessObject.php
includes/db/Database.php
includes/db/loadbalancer/LBFactoryMulti.php
includes/db/loadbalancer/LBFactorySimple.php
includes/db/loadbalancer/LoadBalancer.php
includes/deferred/DeferredUpdates.php
includes/deferred/SiteStatsUpdate.php
includes/diff/DifferenceEngine.php
includes/externalstore/ExternalStoreDB.php
includes/filerepo/FileBackendDBRepoWrapper.php
includes/filerepo/ForeignDBViaLBRepo.php
includes/filerepo/LocalRepo.php
includes/filerepo/file/ArchivedFile.php
includes/import/WikiImporter.php
includes/interwiki/ClassicInterwikiLookup.php
includes/jobqueue/JobQueue.php
includes/jobqueue/JobQueueDB.php
includes/jobqueue/JobQueueGroup.php
includes/jobqueue/JobRunner.php
includes/jobqueue/jobs/CategoryMembershipChangeJob.php
includes/jobqueue/jobs/RecentChangesUpdateJob.php
includes/jobqueue/jobs/RefreshLinksJob.php
includes/libs/objectcache/ReplicatedBagOStuff.php
includes/libs/objectcache/WANObjectCache.php
includes/logging/LogPager.php
includes/objectcache/ObjectCache.php
includes/objectcache/RedisBagOStuff.php
includes/objectcache/SqlBagOStuff.php
includes/page/Article.php
includes/page/ImagePage.php
includes/page/WikiPage.php
includes/pager/IndexPager.php
includes/parser/LinkHolderArray.php
includes/parser/Parser.php
includes/resourceloader/ResourceLoader.php
includes/resourceloader/ResourceLoaderModule.php
includes/resourceloader/ResourceLoaderWikiModule.php
includes/revisiondelete/RevDelLogList.php
includes/revisiondelete/RevisionDeleter.php
includes/search/SearchDatabase.php
includes/search/SearchEngineFactory.php
includes/search/SearchMySQL.php
includes/site/DBSiteStore.php
includes/specialpage/ChangesListSpecialPage.php
includes/specialpage/QueryPage.php
includes/specials/SpecialActiveusers.php
includes/specials/SpecialAllPages.php
includes/specials/SpecialBlockList.php
includes/specials/SpecialBotPasswords.php
includes/specials/SpecialBrokenRedirects.php
includes/specials/SpecialContributions.php
includes/specials/SpecialDeletedContributions.php
includes/specials/SpecialDoubleRedirects.php
includes/specials/SpecialExport.php
includes/specials/SpecialLinkSearch.php
includes/specials/SpecialMediaStatistics.php
includes/specials/SpecialMovepage.php
includes/specials/SpecialPagesWithProp.php
includes/specials/SpecialPrefixindex.php
includes/specials/SpecialRandomInCategory.php
includes/specials/SpecialRandompage.php
includes/specials/SpecialRandomrootpage.php
includes/specials/SpecialRecentchanges.php
includes/specials/SpecialRecentchangeslinked.php
includes/specials/SpecialRedirect.php
includes/specials/SpecialTags.php
includes/specials/SpecialUndelete.php
includes/specials/SpecialVersion.php
includes/specials/SpecialWatchlist.php
includes/specials/SpecialWhatlinkshere.php
includes/specials/SpecialWithoutinterwiki.php
includes/specials/pagers/AllMessagesTablePager.php
includes/specials/pagers/ContribsPager.php
includes/specials/pagers/DeletedContribsPager.php
includes/specials/pagers/ImageListPager.php
includes/specials/pagers/MergeHistoryPager.php
includes/specials/pagers/NewFilesPager.php
includes/specials/pagers/UsersPager.php
includes/upload/UploadStash.php
includes/user/BotPassword.php
includes/user/LocalIdLookup.php
includes/user/PasswordReset.php
includes/user/User.php
includes/user/UserArray.php
includes/user/UserNamePrefixSearch.php
includes/utils/BatchRowUpdate.php
maintenance/Maintenance.php
maintenance/backup.inc
maintenance/benchmarks/benchmarkParse.php
maintenance/checkBadRedirects.php
maintenance/checkImages.php
maintenance/checkUsernames.php
maintenance/cleanupSpam.php
maintenance/cleanupTable.inc
maintenance/cleanupTitles.php
maintenance/clearInterwikiCache.php
maintenance/compareParserCache.php
maintenance/deleteDefaultMessages.php
maintenance/dumpLinks.php
maintenance/dumpTextPass.php
maintenance/dumpUploads.php
maintenance/fetchText.php
maintenance/fixDefaultJsonContentPages.php
maintenance/fixDoubleRedirects.php
maintenance/fixUserRegistration.php
maintenance/generateSitemap.php
maintenance/getReplicaServer.php [new file with mode: 0644]
maintenance/getSlaveServer.php
maintenance/importImages.php
maintenance/initEditCount.php
maintenance/populateFilearchiveSha1.php
maintenance/populateRevisionLength.php
maintenance/purgeChangedFiles.php
maintenance/purgeChangedPages.php
maintenance/purgeList.php
maintenance/rebuildFileCache.php
maintenance/rebuildImages.php
maintenance/rebuildall.php
maintenance/refreshFileHeaders.php
maintenance/refreshLinks.php
maintenance/removeInvalidEmails.php
maintenance/removeUnusedAccounts.php
maintenance/resetUserTokens.php
maintenance/rollbackEdits.php
maintenance/runBatchedQuery.php
maintenance/showSiteStats.php
maintenance/sql.php
maintenance/storage/checkStorage.php
maintenance/storage/compressOld.php
maintenance/storage/dumpRev.php
maintenance/storage/fixBug20757.php
maintenance/storage/moveToExternal.php
maintenance/storage/orphanStats.php
maintenance/storage/recompressTracked.php
maintenance/storage/resolveStubs.php
maintenance/storage/storageTypeStats.php
maintenance/storage/testCompression.php
maintenance/storage/trackBlobs.php
maintenance/tidyUpBug37714.php
maintenance/updateArticleCount.php
maintenance/updateCollation.php
maintenance/updateSpecialPages.php
maintenance/userOptions.inc
resources/Resources.php
resources/src/mediawiki.action/mediawiki.action.history.diff.css [deleted file]
resources/src/mediawiki.action/mediawiki.action.history.diff.print.css [deleted file]
resources/src/mediawiki/mediawiki.diff.styles.css [new file with mode: 0644]
resources/src/mediawiki/mediawiki.diff.styles.print.css [new file with mode: 0644]
tests/phpunit/includes/db/LBFactoryTest.php

index 652535c..0c63ba5 100644 (file)
@@ -509,7 +509,7 @@ $wgAutoloadLocalClasses = [
        'GenericArrayObject' => __DIR__ . '/includes/libs/GenericArrayObject.php',
        'GetConfiguration' => __DIR__ . '/maintenance/getConfiguration.php',
        'GetLagTimes' => __DIR__ . '/maintenance/getLagTimes.php',
-       'GetSlaveServer' => __DIR__ . '/maintenance/getSlaveServer.php',
+       'GetSlaveServer' => __DIR__ . '/maintenance/getReplicaServer.php',
        'GetTextMaint' => __DIR__ . '/maintenance/getText.php',
        'GitInfo' => __DIR__ . '/includes/GitInfo.php',
        'GlobalDependency' => __DIR__ . '/includes/cache/CacheDependency.php',
diff --git a/docs/uidesign/mediawiki.action.history.diff.html b/docs/uidesign/mediawiki.action.history.diff.html
deleted file mode 100644 (file)
index 615558f..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-<!DOCTYPE html>
-<html lang="en" dir="ltr">
-<head>
-       <meta charset="utf-8">
-       <link rel="stylesheet" href="../../resources/src/mediawiki.action/mediawiki.action.history.diff.css">
-       <link rel="stylesheet" media="print" href="../../resources/src/mediawiki.action/mediawiki.action.history.diff.print.css">
-</head>
-<body>
-
-<p>This show various styles for our diff action. Style sheet: <code><a href="../../resources/src/mediawiki.action/mediawiki.action.history.diff.css">resources/src/mediawiki.action/mediawiki.action.history.diff.css</a></code>.</p>
-<p>This file might help us fix our diff colors which have been a recurring issues among the community for a loooong time.</p>
-<p>Try it out in print mode, too. Style sheet: <code><a href="../../resources/src/mediawiki.action/mediawiki.action.history.diff.print.css">resources/src/mediawiki.action/mediawiki.action.history.diff.print.css</a></code>.</p>
-
-<p>Practical example copied from MediaWiki's HTML output:</p>
-
-<table class="diff diff-contentalign-left">
-       <colgroup><col class="diff-marker">
-       <col class="diff-content">
-       <col class="diff-marker">
-       <col class="diff-content">
-       </colgroup>
-<tbody>
-<tr>
-       <td class="diff-marker">−</td>
-       <td class="diff-deletedline"><div>Lorem ipsum dolor sit amet<del class="diffchange diffchange-inline">, consectetur adipisicing elit</del>, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</div></td>
-       <td class="diff-marker">+</td>
-       <td class="diff-addedline"><div>Lorem ipsum dolor sit amet, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</div></td>
-</tr>
-<tr>
-       <td class="diff-marker">−</td>
-       <td class="diff-deletedline"></td>
-       <td colspan="2" class="diff-empty">&nbsp;</td>
-</tr>
-<tr>
-       <td class="diff-marker">−</td>
-       <td class="diff-deletedline"><div>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div></td>
-       <td colspan="2" class="diff-empty">&nbsp;</td>
-</tr>
-<tr>
-       <td class="diff-marker">&nbsp;</td>
-       <td class="diff-context"></td>
-       <td class="diff-marker">&nbsp;</td>
-       <td class="diff-context"></td>
-</tr>
-<tr>
-       <td class="diff-marker">&nbsp;</td>
-       <td class="diff-context"><div>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</div></td>
-       <td class="diff-marker">&nbsp;</td>
-       <td class="diff-context"><div>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</div></td>
-</tr>
-<tr>
-       <td class="diff-marker">&nbsp;</td>
-       <td class="diff-context"></td>
-       <td class="diff-marker">&nbsp;</td>
-       <td class="diff-context"></td>
-</tr>
-<tr>
-       <td class="diff-marker">−</td>
-       <td class="diff-deletedline"><div>Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim<del class="diffchange diffchange-inline"> id est laborum</del>.</div></td>
-       <td class="diff-marker">+</td>
-       <td class="diff-addedline"><div>Excepteur sint occaecat cupidatat non proident, sunt<ins class="diffchange diffchange-inline"> reprehenderit in voluptate</ins> in culpa qui officia deserunt mollit anim.</div></td>
-</tr>
-<tr>
-       <td colspan="2" class="diff-empty">&nbsp;</td>
-       <td class="diff-marker">+</td>
-       <td class="diff-addedline"></td>
-</tr>
-<tr>
-       <td colspan="2" class="diff-empty">&nbsp;</td>
-       <td class="diff-marker">+</td>
-       <td class="diff-addedline"><div>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div></td>
-</tr>
-</tbody></table>
-
-<p>Below are some basic lines being applied one or two classes. Mainly for debugging purposes.</p>
-
-<table class="diff">
-       <tr><th>Diff</th></tr>
-
-       <tr><td class="diff-addedline"><code>diff-addedline</code>: added line</td></tr>
-       <tr><td class="diff-deletedline"><code>diff-deletedline</code>: deleted line</td></tr>
-       <tr><td class="diff-context"><code>diff-context</code>: context</td></tr>
-
-       <tr><th>Same as above with a <code>&lt;ins&gt;</code> or <code>&lt;del&gt;</code> child element having the <code>diffchange</code> class:</th></tr>
-
-       <tr><td class="diffchange">Diffchange</td></tr>
-       <tr><td class="diff-addedline"><ins class="diffchange">Added line + diffchange</ins></td></tr>
-       <tr><td class="diff-deletedline"><del class="diffchange">Deleted line + diffchange</del></td></tr>
-</table>
-
-</body>
-</html>
diff --git a/docs/uidesign/mediawiki.diff.html b/docs/uidesign/mediawiki.diff.html
new file mode 100644 (file)
index 0000000..0372595
--- /dev/null
@@ -0,0 +1,92 @@
+<!DOCTYPE html>
+<html lang="en" dir="ltr">
+<head>
+       <meta charset="utf-8">
+       <link rel="stylesheet" href="../../resources/src/mediawiki/mediawiki.diff.styles.css">
+       <link rel="stylesheet" media="print" href="../../resources/src/mediawiki/mediawiki.diff.styles.print.css">
+</head>
+<body>
+
+<p>This show various styles for our diff action. Style sheet: <code><a href="../../resources/src/mediawiki/mediawiki.diff.styles.css">resources/src/mediawiki/mediawiki.diff.styles.css</a></code>.</p>
+<p>This file might help us fix our diff colors which have been a recurring issues among the community for a loooong time.</p>
+<p>Try it out in print mode, too. Style sheet: <code><a href="../../resources/src/mediawiki/mediawiki.diff.styles.print.css">resources/src/mediawiki/mediawiki.diff.styles.print.css</a></code>.</p>
+
+<p>Practical example copied from MediaWiki's HTML output:</p>
+
+<table class="diff diff-contentalign-left">
+       <colgroup><col class="diff-marker">
+       <col class="diff-content">
+       <col class="diff-marker">
+       <col class="diff-content">
+       </colgroup>
+<tbody>
+<tr>
+       <td class="diff-marker">−</td>
+       <td class="diff-deletedline"><div>Lorem ipsum dolor sit amet<del class="diffchange diffchange-inline">, consectetur adipisicing elit</del>, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</div></td>
+       <td class="diff-marker">+</td>
+       <td class="diff-addedline"><div>Lorem ipsum dolor sit amet, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</div></td>
+</tr>
+<tr>
+       <td class="diff-marker">−</td>
+       <td class="diff-deletedline"></td>
+       <td colspan="2" class="diff-empty">&nbsp;</td>
+</tr>
+<tr>
+       <td class="diff-marker">−</td>
+       <td class="diff-deletedline"><div>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div></td>
+       <td colspan="2" class="diff-empty">&nbsp;</td>
+</tr>
+<tr>
+       <td class="diff-marker">&nbsp;</td>
+       <td class="diff-context"></td>
+       <td class="diff-marker">&nbsp;</td>
+       <td class="diff-context"></td>
+</tr>
+<tr>
+       <td class="diff-marker">&nbsp;</td>
+       <td class="diff-context"><div>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</div></td>
+       <td class="diff-marker">&nbsp;</td>
+       <td class="diff-context"><div>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</div></td>
+</tr>
+<tr>
+       <td class="diff-marker">&nbsp;</td>
+       <td class="diff-context"></td>
+       <td class="diff-marker">&nbsp;</td>
+       <td class="diff-context"></td>
+</tr>
+<tr>
+       <td class="diff-marker">−</td>
+       <td class="diff-deletedline"><div>Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim<del class="diffchange diffchange-inline"> id est laborum</del>.</div></td>
+       <td class="diff-marker">+</td>
+       <td class="diff-addedline"><div>Excepteur sint occaecat cupidatat non proident, sunt<ins class="diffchange diffchange-inline"> reprehenderit in voluptate</ins> in culpa qui officia deserunt mollit anim.</div></td>
+</tr>
+<tr>
+       <td colspan="2" class="diff-empty">&nbsp;</td>
+       <td class="diff-marker">+</td>
+       <td class="diff-addedline"></td>
+</tr>
+<tr>
+       <td colspan="2" class="diff-empty">&nbsp;</td>
+       <td class="diff-marker">+</td>
+       <td class="diff-addedline"><div>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</div></td>
+</tr>
+</tbody></table>
+
+<p>Below are some basic lines being applied one or two classes. Mainly for debugging purposes.</p>
+
+<table class="diff">
+       <tr><th>Diff</th></tr>
+
+       <tr><td class="diff-addedline"><code>diff-addedline</code>: added line</td></tr>
+       <tr><td class="diff-deletedline"><code>diff-deletedline</code>: deleted line</td></tr>
+       <tr><td class="diff-context"><code>diff-context</code>: context</td></tr>
+
+       <tr><th>Same as above with a <code>&lt;ins&gt;</code> or <code>&lt;del&gt;</code> child element having the <code>diffchange</code> class:</th></tr>
+
+       <tr><td class="diffchange">Diffchange</td></tr>
+       <tr><td class="diff-addedline"><ins class="diffchange">Added line + diffchange</ins></td></tr>
+       <tr><td class="diff-deletedline"><del class="diffchange">Deleted line + diffchange</del></td></tr>
+</table>
+
+</body>
+</html>
index 79b31bb..19ba0a2 100644 (file)
@@ -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() ];
@@ -1110,7 +1110,7 @@ class Block {
         * @param array $ipChain List of IPs (strings), usually retrieved from the
         *         X-Forwarded-For header of the request
         * @param bool $isAnon Exclude anonymous-only blocks if false
-        * @param bool $fromMaster Whether to query the master or slave database
+        * @param bool $fromMaster Whether to query the master or replica DB
         * @return array Array of Blocks
         * @since 1.22
         */
@@ -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 ) {
index 531e0be..1ebd605 100644 (file)
@@ -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' ];
index 3d5e6c5..4efa2ff 100644 (file)
@@ -64,7 +64,7 @@ class CategoryFinder {
        /** @var string "AND" or "OR" */
        protected $mode;
 
-       /** @var IDatabase Read-DB slave */
+       /** @var IDatabase Read-DB replica DB */
        protected $dbr;
 
        /**
@@ -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();
                }
index 490f548..a8e988f 100644 (file)
@@ -286,7 +286,7 @@ class CategoryViewer extends ContextSource {
        }
 
        function doCategoryQuery() {
-               $dbr = wfGetDB( DB_SLAVE, 'category' );
+               $dbr = wfGetDB( DB_REPLICA, 'category' );
 
                $this->nextPage = [
                        'page' => null,
index a378c38..664718a 100644 (file)
@@ -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.
@@ -1913,7 +1913,7 @@ $wgSharedSchema = false;
  *                  - DBO_COMPRESS -- uses internal compression in database connections,
  *                                    if available
  *
- *   - max lag:     (optional) Maximum replication lag before a slave will taken out of rotation
+ *   - max lag:     (optional) Maximum replication lag before a replica DB goes out of rotation
  *   - is static:   (optional) Set to true if the dataset is static and no replication is used.
  *   - cliMode:     (optional) Connection handles will not assume that requests are short-lived
  *                  nor that INSERT..SELECT can be rewritten into a buffered SELECT and INSERT.
@@ -1927,15 +1927,15 @@ $wgSharedSchema = false;
  * perhaps in some command-line scripts).
  *
  * The first server listed in this array (with key 0) will be the master. The
- * rest of the servers will be slaves. To prevent writes to your slaves due to
+ * rest of the servers will be replica DBs. To prevent writes to your replica DBs due to
  * accidental misconfiguration or MediaWiki bugs, set read_only=1 on all your
- * slaves in my.cnf. You can set read_only mode at runtime using:
+ * replica DBs in my.cnf. You can set read_only mode at runtime using:
  *
  * @code
  *     SET @@read_only=1;
  * @endcode
  *
- * Since the effect of writing to a slave is so damaging and difficult to clean
+ * Since the effect of writing to a replica DB is so damaging and difficult to clean
  * up, we at Wikimedia set read_only=1 in my.cnf on all our DB servers, even
  * our masters, and then set read_only=0 on masters at runtime.
  */
@@ -2661,7 +2661,7 @@ $wgInternalServer = false;
 $wgSquidMaxage = 18000;
 
 /**
- * Cache timeout for the CDN when DB slave lag is high
+ * Cache timeout for the CDN when DB replica DB lag is high
  * @see $wgSquidMaxage
  * @since 1.27
  */
@@ -2671,7 +2671,7 @@ $wgCdnMaxageLagged = 30;
  * If set, any SquidPurge call on a URL or URLs will send a second purge no less than
  * this many seconds later via the job queue. This requires delayed job support.
  * This should be safely higher than the 'max lag' value in $wgLBFactoryConf, so that
- * slave lag does not cause page to be stuck in stales states in CDN.
+ * replica DB lag does not cause page to be stuck in stales states in CDN.
  *
  * This also fixes race conditions in two-tiered CDN setups (e.g. cdn2 => cdn1 => MediaWiki).
  * If a purge for a URL reaches cdn2 before cdn1 and a request reaches cdn2 for that URL,
@@ -7220,8 +7220,8 @@ $wgJobTypesExcludedFromDefaultQueue = [ 'AssembleUploadChunks', 'PublishStashedF
 $wgJobBackoffThrottling = [];
 
 /**
- * Make job runners commit changes for slave-lag prone jobs one job at a time.
- * This is useful if there are many job workers that race on slave lag checks.
+ * Make job runners commit changes for replica DB-lag prone jobs one job at a time.
+ * This is useful if there are many job workers that race on replica DB lag checks.
  * If set, jobs taking this many seconds of DB write time have serialized commits.
  *
  * Note that affected jobs may have worse lock contention. Also, if they affect
@@ -7843,7 +7843,7 @@ $wgAPIMaxResultSize = 8388608;
 $wgAPIMaxUncachedDiffs = 1;
 
 /**
- * Maximum amount of DB lag on a majority of DB slaves to tolerate
+ * Maximum amount of DB lag on a majority of DB replica DBs to tolerate
  * before forcing bots to retry any write requests via API errors.
  * This should be lower than the 'max lag' value in $wgLBFactoryConf.
  */
index fe5083e..d0105ab 100644 (file)
@@ -43,11 +43,12 @@ define( 'DBO_COMPRESS', 512 );
  * Valid database indexes
  * Operation-based indexes
  */
-define( 'DB_SLAVE', -1 );     # Read from the slave (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 );
 
index e0080fa..b98c908 100644 (file)
@@ -3613,7 +3613,7 @@ HTML
         * @return bool|stdClass
         */
        protected function getLastDelete() {
-               $dbr = wfGetDB( DB_SLAVE );
+               $dbr = wfGetDB( DB_REPLICA );
                $data = $dbr->selectRow(
                        [ 'logging', 'user' ],
                        [
index b421f96..bc78be5 100644 (file)
@@ -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 slave 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.
  *
@@ -3279,10 +3279,10 @@ function wfGetNull() {
 }
 
 /**
- * Waits for the slaves to catch up to the master position
+ * Waits for the replica DBs to catch up to the master position
  *
  * Use this when updating very large numbers of rows, as in maintenance scripts,
- * to avoid causing too much lag. Of course, this is a no-op if there are no slaves.
+ * to avoid causing too much lag. Of course, this is a no-op if there are no replica DBs.
  *
  * By default this waits on the main DB cluster of the current wiki.
  * If $cluster is set to "*" it will wait on all DB clusters, including
index 8673125..b17a2f5 100644 (file)
@@ -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;
index 802bfbe..d86291a 100644 (file)
@@ -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 );
index f8b1bae..bcc348e 100644 (file)
@@ -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(
index 35aa610..77a1969 100644 (file)
@@ -580,7 +580,7 @@ class MediaWiki {
                        $request->response()->setCookie( 'UseCDNCache', 'false', $expires, $options );
                }
 
-               // Avoid letting a few seconds of slave lag cause a month of stale data. This logic is
+               // Avoid letting a few seconds of replica DB lag cause a month of stale data. This logic is
                // also intimately related to the value of $wgCdnReboundPurgeDelay.
                if ( $factory->laggedReplicaUsed() ) {
                        $maxAge = $config->get( 'CdnMaxageLagged' );
index 441fe9e..dd1fd37 100644 (file)
@@ -33,7 +33,7 @@
  */
 class MergeHistory {
 
-       /** @const int Maximum number of revisions that can be merged at once (avoid too much slave lag) */
+       /** @const int Maximum number of revisions that can be merged at once */
        const REVISION_LIMIT = 5000;
 
        /** @var Title Page from which history will be merged */
index 5aaa474..6ae2a92 100644 (file)
@@ -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' ]
@@ -2535,7 +2535,7 @@ class OutputPage extends ContextSource {
        }
 
        /**
-        * Show a warning about slave lag
+        * Show a warning about replica DB lag
         *
         * If the lag is higher than $wgSlaveLagCritical seconds,
         * then the warning is a bit more obvious. If the lag is
index 5579ba5..ed06935 100644 (file)
@@ -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',
                                [
index 0039d2b..bd1b2a2 100644 (file)
@@ -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 ) {
index 04c68ca..49e596d 100644 (file)
@@ -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' ],
                        [
index 36e27bd..03c3e6d 100644 (file)
@@ -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 );
                }
        }
@@ -309,14 +309,14 @@ class Revision implements IDBAccessObject {
         * Given a set of conditions, fetch a revision
         *
         * This method is used then a revision ID is qualified and
-        * will incorporate some basic slave/master fallback logic
+        * will incorporate some basic replica DB/master fallback logic
         *
         * @param array $conditions
         * @param int $flags (optional)
         * @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 );
 
@@ -1609,15 +1609,15 @@ class Revision implements IDBAccessObject {
                }
 
                if ( !$row ) {
-                       // Text data is immutable; check slaves first.
-                       $dbr = wfGetDB( DB_SLAVE );
+                       // Text data is immutable; check replica DBs first.
+                       $dbr = wfGetDB( DB_REPLICA );
                        $row = $dbr->selectRow( 'text',
                                [ 'old_text', 'old_flags' ],
                                [ 'old_id' => $textId ],
                                __METHOD__ );
                }
 
-               // Fallback to the master in case of slave lag. Also use FOR UPDATE if it was
+               // Fallback to the master in case of replica DB lag. Also use FOR UPDATE if it was
                // used to fetch this revision to avoid missing the row due to REPEATABLE-READ.
                $forUpdate = ( $this->mQueryFlags & self::READ_LOCKING == self::READ_LOCKING );
                if ( !$row && ( $forUpdate || wfGetLB()->getServerCount() > 1 ) ) {
@@ -1638,7 +1638,7 @@ class Revision implements IDBAccessObject {
                        wfDebugLog( 'Revision', "No blob for text row '$textId' (revision {$this->getId()})." );
                }
 
-               # No negative caching -- negative hits on text rows may be due to corrupted slave servers
+               # No negative caching -- negative hits on text rows may be due to corrupted replica DB servers
                if ( $wgRevisionCacheExpiry && $text !== false ) {
                        $processCache->set( $key, $text );
                        $cache->set( $key, $text, $wgRevisionCacheExpiry );
@@ -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' ],
index 811870c..fb444bd 100644 (file)
@@ -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();
                }
index 604ab93..ff7875c 100644 (file)
@@ -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;
@@ -71,12 +71,12 @@ class SiteStats {
        static function loadAndLazyInit() {
                global $wgMiserMode;
 
-               wfDebug( __METHOD__ . ": reading site_stats from slave\n" );
-               $row = self::doLoad( wfGetDB( DB_SLAVE ) );
+               wfDebug( __METHOD__ . ": reading site_stats from replica DB\n" );
+               $row = self::doLoad( wfGetDB( DB_REPLICA ) );
 
                if ( !self::isSane( $row ) ) {
                        // Might have just been initialized during this request? Underflow?
-                       wfDebug( __METHOD__ . ": site_stats damaged or missing on slave\n" );
+                       wfDebug( __METHOD__ . ": site_stats damaged or missing on replica DB\n" );
                        $row = self::doLoad( wfGetDB( DB_MASTER ) );
                }
 
@@ -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' );
                }
        }
 
index 2021e0a..24bad81 100644 (file)
@@ -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',
@@ -1886,8 +1886,8 @@ class Title implements LinkTarget {
         * @param string $action Action that permission needs to be checked for
         * @param User $user User to check
         * @param string $rigor One of (quick,full,secure)
-        *   - quick  : does cheap permission checks from slaves (usable for GUI creation)
-        *   - full   : does cheap and expensive checks possibly from a slave
+        *   - quick  : does cheap permission checks from replica DBs (usable for GUI creation)
+        *   - full   : does cheap and expensive checks possibly from a replica DB
         *   - secure : does cheap and expensive checks, using the master as needed
         * @param array $ignoreErrors Array of Strings Set this to a list of message keys
         *   whose corresponding errors may be ignored.
@@ -2416,8 +2416,8 @@ class Title implements LinkTarget {
         * @param string $action Action that permission needs to be checked for
         * @param User $user User to check
         * @param string $rigor One of (quick,full,secure)
-        *   - quick  : does cheap permission checks from slaves (usable for GUI creation)
-        *   - full   : does cheap and expensive checks possibly from a slave
+        *   - quick  : does cheap permission checks from replica DBs (usable for GUI creation)
+        *   - full   : does cheap and expensive checks possibly from a replica DB
         *   - secure : does cheap and expensive checks, using the master as needed
         * @param bool $short Set this to true to stop after the first permission error.
         * @return array Array of arrays of the arguments to wfMessage to explain permissions problems.
@@ -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(),
index 3dcd30f..4ac4dea 100644 (file)
@@ -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' ] );
        }
 
        /**
index a13609b..9a74401 100644 (file)
@@ -190,13 +190,13 @@ class WatchedItemStore implements StatsdAwareInterface {
        }
 
        /**
-        * @param int $slaveOrMaster DB_MASTER or DB_SLAVE
+        * @param int $dbIndex DB_MASTER or DB_REPLICA
         *
         * @return DatabaseBase
         * @throws MWException
         */
-       private function getConnection( $slaveOrMaster ) {
-               return $this->loadBalancer->getConnection( $slaveOrMaster, [ 'watchlist' ] );
+       private function getConnection( $dbIndex ) {
+               return $this->loadBalancer->getConnection( $dbIndex, [ 'watchlist' ] );
        }
 
        /**
@@ -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',
index 0df372e..41378fb 100644 (file)
@@ -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", ">=" ];
index ea66900..43bff87 100644 (file)
@@ -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 );
 
index 55d2430..f763e45 100644 (file)
@@ -599,12 +599,12 @@ abstract class ApiBase extends ContextSource {
        }
 
        /**
-        * Gets a default slave database connection object
+        * Gets a default replica DB connection object
         * @return DatabaseBase
         */
        protected function getDB() {
                if ( !isset( $this->mSlaveDB ) ) {
-                       $this->mSlaveDB = wfGetDB( DB_SLAVE, 'api' );
+                       $this->mSlaveDB = wfGetDB( DB_REPLICA, 'api' );
                }
 
                return $this->mSlaveDB;
@@ -826,7 +826,7 @@ abstract class ApiBase extends ContextSource {
         * @param array $params
         * @param bool|string $load Whether load the object's state from the database:
         *        - false: don't load (if the pageid is given, it will still be loaded)
-        *        - 'fromdb': load from a slave database
+        *        - 'fromdb': load from a replica DB
         *        - 'fromdbmaster': load from the master database
         * @return WikiPage
         */
index 22b079d..1f3c76a 100644 (file)
@@ -1322,9 +1322,9 @@ class ApiMain extends ApiBase {
                        }
                }
 
-               // If a majority of slaves are too lagged then disallow writes
-               $slaveCount = wfGetLB()->getServerCount() - 1;
-               if ( $numLagged >= ceil( $slaveCount / 2 ) ) {
+               // If a majority of replica DBs are too lagged then disallow writes
+               $replicaCount = wfGetLB()->getServerCount() - 1;
+               if ( $numLagged >= ceil( $replicaCount / 2 ) ) {
                        $laggedServers = implode( ', ', $laggedServers );
                        wfDebugLog(
                                'api-readonly',
index 51e1923..f92a916 100644 (file)
@@ -57,13 +57,13 @@ class ApiQueryContributions extends ApiQueryBase {
                $this->fld_patrolled = isset( $prop['patrolled'] );
                $this->fld_tags = isset( $prop['tags'] );
 
-               // Most of this code will use the 'contributions' group DB, which can map to slaves
+               // Most of this code will use the 'contributions' group DB, which can map to replica DBs
                // with extra user based indexes or partioning by user. The additional metadata
-               // queries should use a regular slave since the lookup pattern is not all by user.
-               $dbSecondary = $this->getDB(); // any random slave
+               // queries should use a regular replica DB since the lookup pattern is not all by user.
+               $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'] ) ) {
index e2599d1..c30f0cf 100644 (file)
@@ -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();
 
index 297c0fb..bbfc17a 100644 (file)
@@ -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() ],
index c2d1e0d..f88c2db 100644 (file)
@@ -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;
index a5c86be..992e70f 100644 (file)
@@ -1540,7 +1540,7 @@ class AuthManager implements LoggerAwareInterface {
 
                $username = $user->getName();
 
-               // Try the local user from the slave DB
+               // Try the local user from the replica DB
                $localId = User::idFromName( $username );
                $flags = User::READ_NORMAL;
 
index c338284..f5571c7 100644 (file)
@@ -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' ],
index 8c2a19e..9dfabfd 100644 (file)
@@ -137,13 +137,13 @@ class BacklinkCache {
        }
 
        /**
-        * Get the slave connection to the database
+        * Get the replica DB connection to the database
         * When non existing, will initialize the connection.
         * @return DatabaseBase
         */
        protected function getDB() {
                if ( !isset( $this->db ) ) {
-                       $this->db = wfGetDB( DB_SLAVE );
+                       $this->db = wfGetDB( DB_REPLICA );
                }
 
                return $this->db;
index 80f04ce..a34d235 100644 (file)
@@ -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 ];
index ec37dd6..e6d8630 100644 (file)
@@ -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(),
index 3fd29f3..6a602df 100644 (file)
@@ -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() ],
index 279898c..90ad241 100644 (file)
@@ -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;
        }
@@ -179,7 +179,7 @@ class MessageBlobStore implements LoggerAwareInterface {
        public function updateMessage( $key ) {
                $moduleNames = $this->getResourceLoader()->getModulesByMessage( $key );
                foreach ( $moduleNames as $moduleName ) {
-                       // Uses a holdoff to account for database slave lag (for MessageCache)
+                       // Uses a holdoff to account for database replica DB lag (for MessageCache)
                        $this->wanCache->touchCheckKey( $this->wanCache->makeKey( __CLASS__, $moduleName ) );
                }
        }
index 62fab5f..d254d3d 100644 (file)
@@ -302,7 +302,7 @@ class MessageCache {
                                                $where[] = 'global cache is expired';
                                                $staleCache = $cache;
                                        } elseif ( $hashVolatile ) {
-                                               # DB results are slave lag prone until the holdoff TTL passes.
+                                               # DB results are replica DB lag prone until the holdoff TTL passes.
                                                # By then, updates should be reflected in loadFromDBWithLock().
                                                # One thread renerates the cache while others use old values.
                                                $where[] = 'global cache is expired/volatile';
@@ -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 = [];
 
@@ -564,7 +564,7 @@ class MessageCache {
                }
 
                // Mark this cache as definitely "latest" (non-volatile) so
-               // load() calls do try to refresh the cache with slave data
+               // load() calls do try to refresh the cache with replica DB data
                $this->mCache[$code]['LATEST'] = time();
 
                // Update caches if the lock was acquired
index 48d0398..016306a 100644 (file)
@@ -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' ];
index c350178..e7e2d10 100644 (file)
@@ -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(
index 64d8139..515ab05 100644 (file)
@@ -164,7 +164,7 @@ class CategoryMembershipChange {
                /**
                 * T109700 - Default bot flag to true when there is no corresponding RC entry
                 * This means all changes caused by parser functions & Lua on reparse are marked as bot
-                * Also in the case no RC entry could be found due to slave lag
+                * Also in the case no RC entry could be found due to replica DB lag
                 */
                $bot = 1;
                $lastRevId = 0;
index daf76df..df75ae3 100644 (file)
@@ -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 );
index a2945af..c8c5073 100644 (file)
@@ -174,7 +174,7 @@ class ChangeTags {
 
                // Might as well look for rcids and so on.
                if ( !$rc_id ) {
-                       // Info might be out of date, somewhat fractionally, on slave.
+                       // Info might be out of date, somewhat fractionally, on replica DB.
                        // LogEntry/LogPage and WikiPage match rev/log/rc timestamps,
                        // so use that relation to avoid full table scans.
                        if ( $log_id ) {
@@ -201,7 +201,7 @@ class ChangeTags {
                                );
                        }
                } elseif ( !$log_id && !$rev_id ) {
-                       // Info might be out of date, somewhat fractionally, on slave.
+                       // Info might be out of date, somewhat fractionally, on replica DB.
                        $log_id = $dbw->selectField(
                                'recentchanges',
                                'rc_logid',
@@ -313,7 +313,7 @@ class ChangeTags {
                $tagsToAdd = array_diff( $tagsToAdd, $tagsToRemove );
 
                // Update the summary row.
-               // $prevTags can be out of date on slaves, especially when addTags is called consecutively,
+               // $prevTags can be out of date on replica DBs, especially when addTags is called consecutively,
                // causing loss of tags added recently in tag_summary table.
                $prevTags = $dbw->selectField( 'tag_summary', 'ts_tags', $tsConds, __METHOD__ );
                $prevTags = $prevTags ? $prevTags : '';
@@ -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 );
 
index 41fdef5..22db08a 100644 (file)
@@ -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 );
index b98174b..1fc9ae7 100644 (file)
@@ -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 ) ) {
index c24962b..5acf3ae 100644 (file)
  * though certain objects may assume READ_LATEST for common use case or legacy reasons.
  *
  * There are four types of reads:
- *   - READ_NORMAL    : Potentially cached read of data (e.g. from a slave or stale replica)
+ *   - READ_NORMAL    : Potentially cached read of data (e.g. from a replica DB or stale replica)
  *   - READ_LATEST    : Up-to-date read as of transaction start (e.g. from master or a quorum read)
  *   - READ_LOCKING   : Up-to-date read as of now, that locks (shared) the records
  *   - READ_EXCLUSIVE : Up-to-date read as of now, that locks (exclusive) the records
  * All record locks persist for the duration of the transaction.
  *
  * A special constant READ_LATEST_IMMUTABLE can be used for fetching append-only data. Such
- * data is either (a) on a slave and up-to-date or (b) not yet there, but on the master/quorum.
- * Because the data is append-only, it can never be stale on a slave if present.
+ * data is either (a) on a replica DB and up-to-date or (b) not yet there, but on the master/quorum.
+ * Because the data is append-only, it can never be stale on a replica DB if present.
  *
  * Callers should use READ_NORMAL (or pass in no flags) unless the read determines a write.
  * In theory, such cases may require READ_LOCKING, though to avoid contention, READ_LATEST is
@@ -54,7 +54,7 @@
  */
 interface IDBAccessObject {
        /** Constants for object loading bitfield flags (higher => higher QoS) */
-       /** @var integer Read from a slave/non-quorum */
+       /** @var integer Read from a replica DB/non-quorum */
        const READ_NORMAL = 0;
        /** @var integer Read from the master/quorum */
        const READ_LATEST = 1;
@@ -63,7 +63,7 @@ interface IDBAccessObject {
        /** @var integer Read from the master/quorum and lock out other writers and locking readers */
        const READ_EXCLUSIVE = 7; // READ_LOCKING (3) and "FOR UPDATE" (4)
 
-       /** @var integer Read from a slave/non-quorum immutable data, using the master/quorum on miss */
+       /** @var integer Read from a replica DB or without a quorum, using the master/quorum on miss */
        const READ_LATEST_IMMUTABLE = 8;
 
        // Convenience constant for tracking how data was loaded (higher => higher QoS)
index 4d7f858..a011107 100644 (file)
@@ -3228,7 +3228,7 @@ abstract class DatabaseBase implements IDatabase {
         */
        public function getApproximateLagStatus() {
                return [
-                       'lag'   => $this->getLBInfo( 'slave' ) ? $this->getLag() : 0,
+                       'lag'   => $this->getLBInfo( 'replica' ) ? $this->getLag() : 0,
                        'since' => microtime( true )
                ];
        }
index c0f6509..17e01b9 100644 (file)
@@ -353,7 +353,7 @@ class LBFactoryMulti extends LBFactory {
                                }
                                $master = false;
                        } else {
-                               $serverInfo['slave'] = true;
+                               $serverInfo['replica'] = true;
                        }
                        if ( isset( $this->templateOverridesByServer[$serverName] ) ) {
                                $serverInfo = $this->templateOverridesByServer[$serverName] + $serverInfo;
index c06b5b1..262b0d9 100644 (file)
@@ -54,7 +54,7 @@ class LBFactorySimple extends LBFactory {
                                if ( $i == 0 ) {
                                        $server['master'] = true;
                                } else {
-                                       $server['slave'] = true;
+                                       $server['replica'] = true;
                                }
                                $server += [ 'flags' => DBO_DEFAULT ];
                        }
index 7cdd490..d29f05a 100644 (file)
@@ -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
@@ -1687,7 +1687,7 @@ class LoadBalancer {
         * @since 1.27
         */
        public function safeWaitForMasterPos( IDatabase $conn, $pos = false, $timeout = 10 ) {
-               if ( $this->getServerCount() == 1 || !$conn->getLBInfo( 'slave' ) ) {
+               if ( $this->getServerCount() == 1 || !$conn->getLBInfo( 'replica' ) ) {
                        return true; // server is not a replica DB
                }
 
index 24c7930..8de7cd9 100644 (file)
@@ -221,9 +221,10 @@ class DeferredUpdates {
        private static function runUpdate( DeferrableUpdate $update, LBFactory $lbFactory, $stage ) {
                $guiError = null;
                try {
-                       $lbFactory->beginMasterChanges( __METHOD__ );
+                       $fnameTrxOwner = get_class( $update ) . '::doUpdate';
+                       $lbFactory->beginMasterChanges( $fnameTrxOwner );
                        $update->doUpdate();
-                       $lbFactory->commitMasterChanges( __METHOD__ );
+                       $lbFactory->commitMasterChanges( $fnameTrxOwner );
                } catch ( Exception $e ) {
                        // Reporting GUI exceptions does not work post-send
                        if ( $e instanceof ErrorPageError && $stage === self::PRESEND ) {
index 30aae15..d8bc35b 100644 (file)
@@ -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(
index baec396..1537535 100644 (file)
@@ -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() ),
@@ -695,10 +695,10 @@ class DifferenceEngine extends ContextSource {
        }
 
        /**
-        * Add style sheets and supporting JS for diff display.
+        * Add style sheets for diff display.
         */
        public function showDiffStyle() {
-               $this->getOutput()->addModuleStyles( 'mediawiki.action.history.diff' );
+               $this->getOutput()->addModuleStyles( 'mediawiki.diff.styles' );
        }
 
        /**
@@ -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',
index b454577..2eae279 100644 (file)
@@ -112,7 +112,7 @@ class ExternalStoreDB extends ExternalStoreMedium {
        }
 
        /**
-        * Get a slave database connection for the specified cluster
+        * Get a replica DB connection for the specified cluster
         *
         * @param string $cluster Cluster name
         * @return IDatabase
@@ -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;
@@ -264,7 +264,7 @@ class ExternalStoreDB extends ExternalStoreMedium {
        }
 
        /**
-        * Helper function for self::batchFetchBlobs for merging master/slave results
+        * Helper function for self::batchFetchBlobs for merging master/replica DB results
         * @param array &$ret Current self::batchFetchBlobs return value
         * @param array &$ids Map from blob_id to requested itemIDs
         * @param mixed $res DB result from Database::select
index aec337e..1065223 100644 (file)
@@ -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 = [];
index a59ca34..f8b1ed9 100644 (file)
@@ -63,7 +63,7 @@ class ForeignDBViaLBRepo extends LocalRepo {
         * @return IDatabase
         */
        function getSlaveDB() {
-               return wfGetDB( DB_SLAVE, [], $this->wiki );
+               return wfGetDB( DB_REPLICA, [], $this->wiki );
        }
 
        /**
index eaec151..fccb755 100644 (file)
@@ -453,11 +453,11 @@ class LocalRepo extends FileRepo {
        }
 
        /**
-        * Get a connection to the slave DB
+        * Get a connection to the replica DB
         * @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() {
index ca1ea84..d1e683a 100644 (file)
@@ -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(),
index 406667e..d1a9bc5 100644 (file)
@@ -377,7 +377,7 @@ class WikiImporter {
                // Update article count statistics (T42009)
                // The normal counting logic in WikiPage->doEditUpdates() is designed for
                // one-revision-at-a-time editing, not bulk imports. In this situation it
-               // suffers from issues of slave lag. We let WikiPage handle the total page
+               // suffers from issues of replica DB lag. We let WikiPage handle the total page
                // and revision count, and we implement our own custom logic for the
                // article (content page) count.
                $page = WikiPage::factory( $title );
index 6ac165a..0e107b3 100644 (file)
@@ -37,7 +37,7 @@ use WANObjectCache;
  * and tree storage backends (SQL, CDB, and plain PHP arrays).
  *
  * All information is loaded on creation when called by $this->fetch( $prefix ).
- * All work is done on slave, because this should *never* change (except during
+ * All work is done on replica DB, because this should *never* change (except during
  * schema updates etc, which aren't wiki-related)
  *
  * @since 1.28
@@ -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 = [];
 
index d64be3c..020a684 100644 (file)
@@ -553,7 +553,7 @@ abstract class JobQueue {
        }
 
        /**
-        * Wait for any slaves or backup servers to catch up.
+        * Wait for any replica DBs or backup servers to catch up.
         *
         * This does nothing for certain queue classes.
         *
index 3a1da13..f6b4d53 100644 (file)
@@ -236,7 +236,7 @@ class JobQueueDB extends JobQueue {
                        }
                        // Build the full list of job rows to insert
                        $rows = array_merge( $rowList, array_values( $rowSet ) );
-                       // Insert the job rows in chunks to avoid slave lag...
+                       // Insert the job rows in chunks to avoid replica DB lag...
                        foreach ( array_chunk( $rows, 50 ) as $rowBatch ) {
                                $dbw->insert( 'job', $rowBatch, $method );
                        }
@@ -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 ) {
index a4b3241..8d57562 100644 (file)
@@ -255,7 +255,7 @@ class JobQueueGroup {
        }
 
        /**
-        * Wait for any slaves or backup queue servers to catch up.
+        * Wait for any replica DBs or backup queue servers to catch up.
         *
         * This does nothing for certain queue classes.
         *
index 112696b..f0d5ece 100644 (file)
@@ -42,7 +42,7 @@ class JobRunner implements LoggerAwareInterface {
        protected $logger;
 
        const MAX_ALLOWED_LAG = 3; // abort if more than this much DB lag is present
-       const LAG_CHECK_PERIOD = 1.0; // check slave lag this many seconds
+       const LAG_CHECK_PERIOD = 1.0; // check replica DB lag this many seconds
        const ERROR_BACKOFF_TTL = 1; // seconds to back off a queue due to errors
 
        /**
@@ -118,7 +118,7 @@ class JobRunner implements LoggerAwareInterface {
                // This check should not block as we want to try other wiki queues.
                list( , $maxLag ) = wfGetLB( wfWikiID() )->getMaxLag();
                if ( $maxLag >= self::MAX_ALLOWED_LAG ) {
-                       $response['reached'] = 'slave-lag-limit';
+                       $response['reached'] = 'replica-lag-limit';
                        return $response;
                }
 
@@ -126,7 +126,7 @@ class JobRunner implements LoggerAwareInterface {
                $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
                $lbFactory->commitAll( __METHOD__ );
 
-               // Catch huge single updates that lead to slave lag
+               // Catch huge single updates that lead to replica DB lag
                $trxProfiler = Profiler::instance()->getTransactionProfiler();
                $trxProfiler->setLogger( LoggerFactory::getInstance( 'DBPerformance' ) );
                $trxProfiler->setExpectations( $wgTrxProfilerLimits['JobRunner'], __METHOD__ );
@@ -141,7 +141,7 @@ class JobRunner implements LoggerAwareInterface {
                $jobsPopped = 0;
                $timeMsTotal = 0;
                $startTime = microtime( true ); // time since jobs started running
-               $lastCheckTime = 1; // timestamp of last slave check
+               $lastCheckTime = 1; // timestamp of last replica DB check
                do {
                        // Sync the persistent backoffs with concurrent runners
                        $backoffs = $this->syncBackoffDeltas( $backoffs, $backoffDeltas, $wait );
@@ -210,7 +210,7 @@ class JobRunner implements LoggerAwareInterface {
                                        break;
                                }
 
-                               // Don't let any of the main DB slaves get backed up.
+                               // Don't let any of the main DB replica DBs get backed up.
                                // This only waits for so long before exiting and letting
                                // other wikis in the farm (on different masters) get a chance.
                                $timePassed = microtime( true ) - $lastCheckTime;
@@ -221,12 +221,12 @@ class JobRunner implements LoggerAwareInterface {
                                                        'timeout' => self::MAX_ALLOWED_LAG
                                                ] );
                                        } catch ( DBReplicationWaitError $e ) {
-                                               $response['reached'] = 'slave-lag-limit';
+                                               $response['reached'] = 'replica-lag-limit';
                                                break;
                                        }
                                        $lastCheckTime = microtime( true );
                                }
-                               // Don't let any queue slaves/backups fall behind
+                               // Don't let any queue replica DBs/backups fall behind
                                if ( $jobsPopped > 0 && ( $jobsPopped % 100 ) == 0 ) {
                                        $group->waitForBackups();
                                }
@@ -288,7 +288,7 @@ class JobRunner implements LoggerAwareInterface {
 
                // Commit all outstanding connections that are in a transaction
                // to get a fresh repeatable read snapshot on every connection.
-               // Note that jobs are still responsible for handling slave lag.
+               // Note that jobs are still responsible for handling replica DB lag.
                $lbFactory->flushReplicaSnapshots( __METHOD__ );
                // Clear out title cache data from prior snapshots
                LinkCache::singleton()->clear();
@@ -490,7 +490,7 @@ class JobRunner implements LoggerAwareInterface {
        /**
         * Issue a commit on all masters who are currently in a transaction and have
         * made changes to the database. It also supports sometimes waiting for the
-        * local wiki's slaves to catch up. See the documentation for
+        * local wiki's replica DBs to catch up. See the documentation for
         * $wgJobSerialCommitThreshold for more.
         *
         * @param Job $job
@@ -513,7 +513,7 @@ class JobRunner implements LoggerAwareInterface {
                                $dbwSerial = false;
                        }
                } else {
-                       // There are no slaves or writes are all to foreign DB (we don't handle that)
+                       // There are no replica DBs or writes are all to foreign DB (we don't handle that)
                        $dbwSerial = false;
                }
 
@@ -532,7 +532,7 @@ class JobRunner implements LoggerAwareInterface {
                        // This will trigger a rollback in the main loop
                        throw new DBError( $dbwSerial, "Timed out waiting on commit queue." );
                }
-               // Wait for the slave DBs to catch up
+               // Wait for the replica DBs to catch up
                $pos = $lb->getMasterPos();
                if ( $pos ) {
                        $lb->waitForAll( $pos );
index b561021..e6f59f3 100644 (file)
@@ -57,10 +57,10 @@ class CategoryMembershipChangeJob extends Job {
                        return false;
                }
 
-               $dbr = wfGetDB( DB_SLAVE, [ 'recentchanges' ] );
-               // Wait till the slave is caught up so that jobs for this page see each others' changes
+               $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 slave to catch up" );
+                       $this->setLastError( "Timed out while waiting for replica DB to catch up" );
                        return false;
                }
                // Clear any stale REPEATABLE-READ snapshot
index 2fd3899..809fb63 100644 (file)
@@ -93,7 +93,7 @@ class RecentChangesUpdateJob extends Job {
                        );
                        if ( $rcIds ) {
                                $dbw->delete( 'recentchanges', [ 'rc_id' => $rcIds ], __METHOD__ );
-                               // There might be more, so try waiting for slaves
+                               // There might be more, so try waiting for replica DBs
                                try {
                                        $factory->commitAndWaitForReplication(
                                                __METHOD__, $ticket, [ 'timeout' => 3 ]
index 9cdb161..b0dcd57 100644 (file)
@@ -40,7 +40,7 @@ class RefreshLinksJob extends Job {
        const PARSE_THRESHOLD_SEC = 1.0;
        /** @var integer Lag safety margin when comparing root job times to last-refresh times */
        const CLOCK_FUDGE = 10;
-       /** @var integer How many seconds to wait for slaves to catch up */
+       /** @var integer How many seconds to wait for replica DBs to catch up */
        const LAG_WAIT_TIMEOUT = 15;
 
        function __construct( Title $title, array $params ) {
@@ -83,7 +83,7 @@ class RefreshLinksJob extends Job {
 
                // Job to update all (or a range of) backlink pages for a page
                if ( !empty( $this->params['recursive'] ) ) {
-                       // When the base job branches, wait for the slaves to catch up to the master.
+                       // When the base job branches, wait for the replica DBs to catch up to the master.
                        // From then on, we know that any template changes at the time the base job was
                        // enqueued will be reflected in backlink page parses when the leaf jobs run.
                        if ( !isset( $params['range'] ) ) {
@@ -182,7 +182,7 @@ class RefreshLinksJob extends Job {
 
                        $skewedTimestamp = $this->params['rootJobTimestamp'];
                        if ( $opportunistic ) {
-                               // Neither clock skew nor DB snapshot/slave lag matter much for such
+                               // Neither clock skew nor DB snapshot/replica DB lag matter much for such
                                // updates; focus on reusing the (often recently updated) cache
                        } else {
                                // For transclusion updates, the template changes must be reflected
index f8dba96..3bc7ae2 100644 (file)
@@ -22,7 +22,7 @@
 
 /**
  * A cache class that directs writes to one set of servers and reads to
- * another. This assumes that the servers used for reads are setup to slave
+ * another. This assumes that the servers used for reads are setup to replica DB
  * those that writes go to. This can easily be used with redis for example.
  *
  * In the WAN scenario (e.g. multi-datacenter case), this is useful when
@@ -42,7 +42,7 @@ class ReplicatedBagOStuff extends BagOStuff {
         *   - writeFactory : ObjectFactory::getObjectFromSpec array yeilding BagOStuff.
         *                    This object will be used for writes (e.g. the master DB).
         *   - readFactory  : ObjectFactory::getObjectFromSpec array yeilding BagOStuff.
-        *                    This object will be used for reads (e.g. a slave DB).
+        *                    This object will be used for reads (e.g. a replica DB).
         *
         * @param array $params
         * @throws InvalidArgumentException
index 0d7da91..200ddfa 100644 (file)
@@ -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( ... );
@@ -377,8 +377,8 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface {
         * @param integer $ttl Seconds to live. Special values are:
         *   - WANObjectCache::TTL_INDEFINITE: Cache forever
         * @param array $opts Options map:
-        *   - lag     : Seconds of slave lag. Typically, this is either the slave lag
-        *               before the data was read or, if applicable, the slave lag before
+        *   - lag     : Seconds of replica DB lag. Typically, this is either the replica DB lag
+        *               before the data was read or, if applicable, the replica DB lag before
         *               the snapshot-isolated transaction the data was read from started.
         *               Default: 0 seconds
         *   - since   : UNIX timestamp of the data in $value. Typically, this is either
@@ -566,7 +566,7 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface {
         * Keys using it via get(), getMulti(), or getWithSetCallback() will
         * be invalidated. It is treated as being HOLDOFF_TTL seconds in the future
         * by those methods to avoid race conditions where dependent keys get updated
-        * with stale values (e.g. from a DB slave).
+        * with stale values (e.g. from a DB replica DB).
         *
         * This is typically useful for keys with hardcoded names or in some cases
         * dynamically generated names where a low number of combinations exist.
@@ -660,8 +660,8 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface {
         *         $cache::TTL_MINUTE,
         *         // Function that derives the new key value
         *         function ( $oldValue, &$ttl, array &$setOpts ) {
-        *             $dbr = wfGetDB( DB_SLAVE );
-        *             // Account for any snapshot/slave lag
+        *             $dbr = wfGetDB( DB_REPLICA );
+        *             // Account for any snapshot/replica DB lag
         *             $setOpts += Database::getCacheSetOptions( $dbr );
         *
         *             return $dbr->selectRow( ... );
@@ -678,8 +678,8 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface {
         *         $cache::TTL_DAY,
         *         // Function that derives the new key value
         *         function ( $oldValue, &$ttl, array &$setOpts ) {
-        *             $dbr = wfGetDB( DB_SLAVE );
-        *             // Account for any snapshot/slave lag
+        *             $dbr = wfGetDB( DB_REPLICA );
+        *             // Account for any snapshot/replica DB lag
         *             $setOpts += Database::getCacheSetOptions( $dbr );
         *
         *             return CatConfig::newFromRow( $dbr->selectRow( ... ) );
@@ -705,8 +705,8 @@ 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 );
-        *             // Account for any snapshot/slave lag
+        *             $dbr = wfGetDB( DB_REPLICA );
+        *             // Account for any snapshot/replica DB lag
         *             $setOpts += Database::getCacheSetOptions( $dbr );
         *
         *             return CatState::newFromResults( $dbr->select( ... ) );
@@ -732,8 +732,8 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface {
         *         10,
         *         // Function that derives the new key value
         *         function ( $oldValue, &$ttl, array &$setOpts ) {
-        *             $dbr = wfGetDB( DB_SLAVE );
-        *             // Account for any snapshot/slave lag
+        *             $dbr = wfGetDB( DB_REPLICA );
+        *             // Account for any snapshot/replica DB lag
         *             $setOpts += Database::getCacheSetOptions( $dbr );
         *
         *             // Start off with the last cached list
@@ -784,7 +784,7 @@ class WANObjectCache implements IExpiringStore, LoggerAwareInterface {
         *   - pcTTL: Process cache the value in this PHP instance for this many seconds. This avoids
         *      network I/O when a key is read several times. This will not cache when the callback
         *      returns false, however. Note that any purges will not be seen while process cached;
-        *      since the callback should use slave DBs and they may be lagged or have snapshot
+        *      since the callback should use replica DBs and they may be lagged or have snapshot
         *      isolation anyway, this should not typically matter.
         *      Default: WANObjectCache::TTL_UNCACHEABLE.
         *   - version: Integer version number. This allows for callers to make breaking changes to
index eeea789..68163c1 100644 (file)
@@ -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() {
index bcdf62f..9ff39a0 100644 (file)
@@ -65,7 +65,7 @@ use MediaWiki\Services\ServiceDisabledException;
  *   Purpose: Ephemeral global storage.
  *   Stored centrally within the primary data-center.
  *   Changes are applied there first and replicated to other DCs (best-effort).
- *   To retrieve the latest value (e.g. not from a slave), use BagOStuff::READ_LATEST.
+ *   To retrieve the latest value (e.g. not from a replica DB), use BagOStuff::READ_LATEST.
  *   This store may be subject to LRU style evictions.
  *
  * - ObjectCache::getInstance( $cacheType )
index c3e0c96..f9d201f 100644 (file)
@@ -363,7 +363,7 @@ class RedisBagOStuff extends BagOStuff {
                                try {
                                        if ( $this->getMasterLinkStatus( $conn ) === 'down' ) {
                                                // If the master cannot be reached, fail-over to the next server.
-                                               // If masters are in data-center A, and slaves in data-center B,
+                                               // If masters are in data-center A, and replica DBs in data-center B,
                                                // this helps avoid the case were fail-over happens in A but not
                                                // to the corresponding server in B (e.g. read/write mismatch).
                                                continue;
@@ -384,10 +384,10 @@ class RedisBagOStuff extends BagOStuff {
        }
 
        /**
-        * Check the master link status of a Redis server that is configured as a slave.
+        * Check the master link status of a Redis server that is configured as a replica DB.
         * @param RedisConnRef $conn
         * @return string|null Master link status (either 'up' or 'down'), or null
-        *  if the server is not a slave.
+        *  if the server is not a replica DB.
         */
        protected function getMasterLinkStatus( RedisConnRef $conn ) {
                $info = $conn->info();
index 0abe64c..3baae50 100644 (file)
@@ -44,7 +44,7 @@ class SqlBagOStuff extends BagOStuff {
        /** @var string */
        protected $tableName = 'objectcache';
        /** @var bool */
-       protected $slaveOnly = false;
+       protected $replicaOnly = false;
        /** @var int */
        protected $syncTimeout = 3;
 
@@ -85,11 +85,11 @@ class SqlBagOStuff extends BagOStuff {
         *                  required to hold the largest shard index. Data will be
         *                  distributed across all tables by key hash. This is for
         *                  MySQL bugs 61735 and 61736.
-        *   - slaveOnly:   Whether to only use slave DBs and avoid triggering
+        *   - slaveOnly:   Whether to only use replica DBs and avoid triggering
         *                  garbage collection logic of expired items. This only
         *                  makes sense if the primary DB is used and only if get()
         *                  calls will be used. This is used by ReplicatedBagOStuff.
-        *   - syncTimeout: Max seconds to wait for slaves to catch up for WRITE_SYNC.
+        *   - syncTimeout: Max seconds to wait for replica DBs to catch up for WRITE_SYNC.
         *
         * @param array $params
         */
@@ -132,7 +132,7 @@ class SqlBagOStuff extends BagOStuff {
                if ( isset( $params['syncTimeout'] ) ) {
                        $this->syncTimeout = $params['syncTimeout'];
                }
-               $this->slaveOnly = !empty( $params['slaveOnly'] );
+               $this->replicaOnly = !empty( $params['slaveOnly'] );
        }
 
        protected function getSeparateMainLB() {
@@ -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->replicaOnly ? DB_REPLICA : DB_MASTER;
                                if ( $this->getSeparateMainLB() ) {
                                        $db = $this->getSeparateMainLB()->getConnection( $index );
                                        $db->clearFlag( DBO_TRX ); // auto-commit mode
@@ -539,7 +539,7 @@ class SqlBagOStuff extends BagOStuff {
        }
 
        protected function garbageCollect() {
-               if ( !$this->purgePeriod || $this->slaveOnly ) {
+               if ( !$this->purgePeriod || $this->replicaOnly ) {
                        // Disabled
                        return;
                }
@@ -807,10 +807,10 @@ class SqlBagOStuff extends BagOStuff {
                        ?: MediaWikiServices::getInstance()->getDBLoadBalancer();
 
                if ( $lb->getServerCount() <= 1 ) {
-                       return true; // no slaves
+                       return true; // no replica DBs
                }
 
-               // Main LB is used; wait for any slaves to catch up
+               // Main LB is used; wait for any replica DBs to catch up
                $masterPos = $lb->getMasterPos();
 
                $loop = new WaitConditionLoop(
index e299f7e..449c9ff 100644 (file)
@@ -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 )',
@@ -1151,7 +1151,7 @@ class Article implements Page {
 
                if ( !$rc ) {
                        // Don't cache: This can be hit if the page gets accessed very fast after
-                       // its creation / latest upload or in case we have high slave lag. In case
+                       // its creation / latest upload or in case we have high replica DB lag. In case
                        // the revision is too old, we will already return above.
                        return false;
                }
@@ -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)',
index 1396685..be5535a 100644 (file)
@@ -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' ],
index e5ce924..8c2d594 100644 (file)
@@ -134,7 +134,7 @@ class WikiPage implements Page, IDBAccessObject {
         *
         * @param int $id Article ID to load
         * @param string|int $from One of the following values:
-        *        - "fromdb" or WikiPage::READ_NORMAL to select from a slave database
+        *        - "fromdb" or WikiPage::READ_NORMAL to select from a replica DB
         *        - "fromdbmaster" or WikiPage::READ_LATEST to select from the master database
         *
         * @return WikiPage|null
@@ -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 ) {
@@ -161,7 +161,7 @@ class WikiPage implements Page, IDBAccessObject {
         * @since 1.20
         * @param object $row Database row containing at least fields returned by selectFields().
         * @param string|int $from Source of $data:
-        *        - "fromdb" or WikiPage::READ_NORMAL: from a slave DB
+        *        - "fromdb" or WikiPage::READ_NORMAL: from a replica DB
         *        - "fromdbmaster" or WikiPage::READ_LATEST: from the master DB
         *        - "forupdate" or WikiPage::READ_LOCKING: from the master DB using SELECT FOR UPDATE
         * @return WikiPage
@@ -346,7 +346,7 @@ class WikiPage implements Page, IDBAccessObject {
         *
         * @param object|string|int $from One of the following:
         *   - A DB query result object.
-        *   - "fromdb" or WikiPage::READ_NORMAL to get from a slave DB.
+        *   - "fromdb" or WikiPage::READ_NORMAL to get from a replica DB.
         *   - "fromdbmaster" or WikiPage::READ_LATEST to get from the master DB.
         *   - "forupdate"  or WikiPage::READ_LOCKING to get from the master DB
         *     using SELECT FOR UPDATE.
@@ -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()
                        ) {
@@ -374,7 +374,7 @@ class WikiPage implements Page, IDBAccessObject {
                                $data = $this->pageDataFromTitle( wfGetDB( $index ), $this->mTitle, $opts );
                        }
                } else {
-                       // No idea from where the caller got this data, assume slave database.
+                       // No idea from where the caller got this data, assume replica DB.
                        $data = $from;
                        $from = self::READ_NORMAL;
                }
@@ -388,7 +388,7 @@ class WikiPage implements Page, IDBAccessObject {
         * @since 1.20
         * @param object|bool $data DB row containing fields returned by selectFields() or false
         * @param string|int $from One of the following:
-        *        - "fromdb" or WikiPage::READ_NORMAL if the data comes from a slave DB
+        *        - "fromdb" or WikiPage::READ_NORMAL if the data comes from a replica DB
         *        - "fromdbmaster" or WikiPage::READ_LATEST if the data comes from the master DB
         *        - "forupdate"  or WikiPage::READ_LOCKING if the data comes from
         *          the master DB using SELECT FOR UPDATE
@@ -552,9 +552,9 @@ class WikiPage implements Page, IDBAccessObject {
         */
        public function getOldestRevision() {
 
-               // Try using the slave database first, then try the master
+               // 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;
@@ -609,7 +609,7 @@ class WikiPage implements Page, IDBAccessObject {
                        $flags = Revision::READ_LOCKING;
                } elseif ( $this->mDataLoadedFrom == self::READ_LATEST ) {
                        // Bug T93976: if page_latest was loaded from the master, fetch the
-                       // revision from there as well, as it may not exist yet on a slave DB.
+                       // revision from there as well, as it may not exist yet on a replica DB.
                        // Also, this keeps the queries in the same REPEATABLE-READ snapshot.
                        $flags = Revision::READ_LATEST;
                } else {
@@ -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
@@ -2110,7 +2110,7 @@ class WikiPage implements Page, IDBAccessObject {
                                // We get here if vary-revision is set. This means that this page references
                                // itself (such as via self-transclusion). In this case, we need to make sure
                                // that any such self-references refer to the newly-saved revision, and not
-                               // to the previous one, which could otherwise happen due to slave lag.
+                               // to the previous one, which could otherwise happen due to replica DB lag.
                                $oldCallback = $edit->popts->getCurrentRevisionCallback();
                                $edit->popts->setCurrentRevisionCallback(
                                        function ( Title $title, $parser = false ) use ( $revision, &$oldCallback ) {
@@ -3323,7 +3323,7 @@ class WikiPage implements Page, IDBAccessObject {
 
                if ( $title->getNamespace() == NS_CATEGORY ) {
                        // Load the Category object, which will schedule a job to create
-                       // the category table row if necessary. Checking a slave is ok
+                       // the category table row if necessary. Checking a replica DB is ok
                        // here, in the worst case it'll run an unnecessary recount job on
                        // a category that probably doesn't have many members.
                        Category::newFromTitle( $title )->getID();
@@ -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',
index a96ca87..395cee5 100644 (file)
@@ -145,8 +145,8 @@ abstract class IndexPager extends ContextSource implements Pager {
                }
 
                $this->mIsBackwards = ( $this->mRequest->getVal( 'dir' ) == 'prev' );
-               # Let the subclass set the DB here; otherwise use a slave DB for the current wiki
-               $this->mDb = $this->mDb ?: wfGetDB( DB_SLAVE );
+               # Let the subclass set the DB here; otherwise use a replica DB for the current wiki
+               $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
index b34ac1f..b32f43b 100644 (file)
@@ -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' ]
index a93400b..b53920b 100644 (file)
@@ -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 ) ] );
index d9cd0ee..fa110e3 100644 (file)
@@ -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
                        }
index de89fc7..43cf78b 100644 (file)
@@ -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',
                                [
index 82051b1..390f785 100644 (file)
@@ -130,7 +130,7 @@ class ResourceLoaderWikiModule extends ResourceLoaderModule {
        /**
         * Get the Database object used in getTitleInfo().
         *
-        * Defaults to the local slave DB. Subclasses may want to override this to return a foreign
+        * Defaults to the local replica DB. Subclasses may want to override this to return a foreign
         * database object, or null if getTitleInfo() shouldn't access the database.
         *
         * NOTE: This ONLY works for getTitleInfo() and isKnownEmpty(), NOT FOR ANYTHING ELSE.
@@ -139,7 +139,7 @@ class ResourceLoaderWikiModule extends ResourceLoaderModule {
         * @return IDatabase|null
         */
        protected function getDB() {
-               return wfGetDB( DB_SLAVE );
+               return wfGetDB( DB_REPLICA );
        }
 
        /**
index 07fe4a1..ff1d2ed 100644 (file)
@@ -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__,
index eea0c28..b834c15 100644 (file)
@@ -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__ );
 
index 5b18b7c..38c60d0 100644 (file)
@@ -40,7 +40,7 @@ class SearchDatabase extends SearchEngine {
                if ( $db ) {
                        $this->db = $db;
                } else {
-                       $this->db = wfGetDB( DB_SLAVE );
+                       $this->db = wfGetDB( DB_REPLICA );
                }
        }
 
index 67f500c..e30869e 100644 (file)
@@ -32,7 +32,7 @@ class SearchEngineFactory {
                } elseif ( $configType !== null ) {
                        $class = $configType;
                } else {
-                       $dbr = wfGetDB( DB_SLAVE );
+                       $dbr = wfGetDB( DB_REPLICA );
                        $class = $dbr->getSearchEngine();
                }
 
index 7e82378..36cbbaa 100644 (file)
@@ -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();
index 974789f..432d5ce 100644 (file)
@@ -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',
index 60f1dd8..01782f3 100644 (file)
@@ -340,7 +340,7 @@ abstract class ChangesListSpecialPage extends SpecialPage {
         * @return IDatabase
         */
        protected function getDB() {
-               return wfGetDB( DB_SLAVE );
+               return wfGetDB( DB_REPLICA );
        }
 
        /**
index 1beac43..afbc581 100644 (file)
@@ -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 );
index c697ca7..2da441b 100644 (file)
@@ -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',
index b55f0b4..4a2a619 100644 (file)
@@ -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;
index de58762..c4fb316 100644 (file)
@@ -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 )
index 7e330aa..61ab642 100644 (file)
@@ -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' ],
index 4c3fbe5..b9b2051 100644 (file)
@@ -49,7 +49,7 @@ class BrokenRedirectsPage extends QueryPage {
        }
 
        public function getQueryInfo() {
-               $dbr = wfGetDB( DB_SLAVE );
+               $dbr = wfGetDB( DB_REPLICA );
 
                return [
                        'tables' => [
index 6aeb2c3..68289a7 100644 (file)
@@ -203,7 +203,7 @@ class SpecialContributions extends IncludableSpecialPage {
                        if ( !$pager->getNumRows() ) {
                                $out->addWikiMsg( 'nocontribs', $target );
                        } else {
-                               # Show a message about slave lag, if applicable
+                               # Show a message about replica DB lag, if applicable
                                $lag = wfGetLB()->safeGetLag( $pager->getDatabase() );
                                if ( $lag > 0 ) {
                                        $out->showLagWarning( $lag );
index 8e168b2..d625f82 100644 (file)
@@ -98,7 +98,7 @@ class DeletedContributionsPage extends SpecialPage {
                        return;
                }
 
-               # Show a message about slave lag, if applicable
+               # Show a message about replica DB lag, if applicable
                $lag = wfGetLB()->safeGetLag( $pager->getDatabase() );
                if ( $lag > 0 ) {
                        $out->showLagWarning( $lag );
index 7b00064..0cec9d0 100644 (file)
@@ -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
index fe97739..bf535a6 100644 (file)
@@ -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 );
index d4886f0..307d6c3 100644 (file)
@@ -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 );
index e51e8b5..ec87716 100644 (file)
@@ -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( ';' ),
index f0b463a..3a12cf3 100644 (file)
@@ -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',
                                [
index 327ddda..706a1d7 100644 (file)
@@ -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',
                        '',
index 87a5b27..5e3e430 100644 (file)
@@ -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,
index a5e538f..fc924a4 100644 (file)
@@ -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(
index d7835d1..e3b567d 100644 (file)
@@ -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(
index 31a290d..0df8423 100644 (file)
@@ -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() );
        }
 
index d4fb72c..8aff690 100644 (file)
@@ -281,7 +281,7 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
        }
 
        protected function getDB() {
-               return wfGetDB( DB_SLAVE, 'recentchanges' );
+               return wfGetDB( DB_REPLICA, 'recentchanges' );
        }
 
        public function outputFeedLinks() {
index 57a3d92..aab0f6d 100644 (file)
@@ -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();
index 80dc797..1d1df6a 100644 (file)
@@ -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
index 47bed62..5e5ed25 100644 (file)
@@ -110,7 +110,7 @@ class SpecialTags extends SpecialPage {
                        // continuing with this, as the user is just going to end up getting sent
                        // somewhere else. Additionally, if we keep going here, we end up
                        // populating the memcache of tag data (see ChangeTags::listDefinedTags)
-                       // with out-of-date data from the slave, because the slave hasn't caught
+                       // with out-of-date data from the replica DB, because the replica DB hasn't caught
                        // up to the fact that a new tag has been created as part of an implicit,
                        // as yet uncommitted transaction on master.
                        if ( $out->getRedirect() !== '' ) {
index 65f0680..91753a9 100644 (file)
@@ -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() ],
index 6f71a51..c8b85ae 100644 (file)
@@ -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
index 17d77ba..99f9c7c 100644 (file)
@@ -313,7 +313,7 @@ class SpecialWatchlist extends ChangesListSpecialPage {
         * @return IDatabase
         */
        protected function getDB() {
-               return wfGetDB( DB_SLAVE, 'watchlist' );
+               return wfGetDB( DB_REPLICA, 'watchlist' );
        }
 
        /**
@@ -343,7 +343,7 @@ class SpecialWatchlist extends ChangesListSpecialPage {
                $user = $this->getUser();
                $output = $this->getOutput();
 
-               # Show a message about slave lag, if applicable
+               # Show a message about replica DB lag, if applicable
                $lag = wfGetLB()->safeGetLag( $dbr );
                if ( $lag > 0 ) {
                        $output->showLagWarning( $lag );
index baa55f0..1ead290 100644 (file)
@@ -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' );
index 259d1f9..a1e5156 100644 (file)
@@ -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() );
                }
 
index ee8b3da..5609310 100644 (file)
@@ -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 ] ],
index f8eba9a..bc0ebc2 100644 (file)
@@ -70,11 +70,11 @@ class ContribsPager extends ReverseChronologicalPager {
                $month = isset( $options['month'] ) ? $options['month'] : false;
                $this->getDateCond( $year, $month );
 
-               // Most of this code will use the 'contributions' group DB, which can map to slaves
+               // Most of this code will use the 'contributions' group DB, which can map to replica DBs
                // with extra user based indexes or partioning by user. The additional metadata
-               // queries should use a regular slave since the lookup pattern is not all by user.
-               $this->mDbSecondary = wfGetDB( DB_SLAVE ); // any random slave
-               $this->mDb = wfGetDB( DB_SLAVE, 'contributions' );
+               // 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_REPLICA, 'contributions' );
        }
 
        function getDefaultQuery() {
index f2421f8..1acbba1 100644 (file)
@@ -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() {
index 5e10269..7fc4a95 100644 (file)
@@ -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 {
index 0b9587c..56229b3 100644 (file)
@@ -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)',
index d1f9f40..41819fc 100644 (file)
@@ -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(
index adc1dd8..901be38 100644 (file)
@@ -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' ],
index 1c3e13b..5bcced8 100644 (file)
@@ -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 ) {
index 49a7163..4ce3cde 100644 (file)
@@ -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 ) {
index f7c5408..0d8b1a8 100644 (file)
@@ -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' ]
                        : [];
index bc87cd0..889ec92 100644 (file)
@@ -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 ],
index 4ec8d54..248ea8e 100644 (file)
@@ -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 ],
@@ -1570,8 +1570,8 @@ class User implements IDBAccessObject {
 
        /**
         * Get blocking information
-        * @param bool $bFromSlave Whether to check the slave database first.
-        *   To improve performance, non-critical checks are done against slaves.
+        * @param bool $bFromSlave Whether to check the replica DB first.
+        *   To improve performance, non-critical checks are done against replica DBs.
         *   Check when actually saving should be done against master.
         */
        private function getBlockedStatus( $bFromSlave = true ) {
@@ -1922,7 +1922,7 @@ class User implements IDBAccessObject {
        /**
         * Check if user is blocked
         *
-        * @param bool $bFromSlave Whether to check the slave database instead of
+        * @param bool $bFromSlave Whether to check the replica DB instead of
         *   the master. Hacked from false due to horrible probs on site.
         * @return bool True if blocked, false otherwise
         */
@@ -1933,7 +1933,7 @@ class User implements IDBAccessObject {
        /**
         * Get the block affecting the user, or null if the user is not blocked
         *
-        * @param bool $bFromSlave Whether to check the slave database instead of the master
+        * @param bool $bFromSlave Whether to check the replica DB instead of the master
         * @return Block|null
         */
        public function getBlock( $bFromSlave = true ) {
@@ -1945,7 +1945,7 @@ class User implements IDBAccessObject {
         * Check if user is blocked from editing a particular article
         *
         * @param Title $title Title to check
-        * @param bool $bFromSlave Whether to check the slave database instead of the master
+        * @param bool $bFromSlave Whether to check the replica DB instead of the master
         * @return bool
         */
        public function isBlockedFrom( $title, $bFromSlave = false ) {
@@ -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',
@@ -3595,7 +3595,7 @@ class User implements IDBAccessObject {
 
                // Only update the timestamp if the page is being watched.
                // The query to find out if it is watched is cached both in memcached and per-invocation,
-               // and when it does have to be executed, it can be on a slave
+               // and when it does have to be executed, it can be on a replica DB
                // If this is the user's newtalk page, we always update the timestamp
                $force = '';
                if ( $title->getNamespace() == NS_USER_TALK && $title->getText() == $this->getName() ) {
@@ -3818,7 +3818,7 @@ class User implements IDBAccessObject {
 
                // Get a new user_touched that is higher than the old one.
                // This will be used for a CAS check as a last-resort safety
-               // check against race conditions and slave lag.
+               // check against race conditions and replica DB lag.
                $newTouched = $this->newTouchedTimestamp();
 
                $dbw = wfGetDB( DB_MASTER );
@@ -3841,7 +3841,7 @@ class User implements IDBAccessObject {
                        // Maybe the problem was a missed cache update; clear it to be safe
                        $this->clearSharedCache( 'refresh' );
                        // User was changed in the meantime or loaded with stale data
-                       $from = ( $this->queryFlagsUsed & self::READ_LATEST ) ? 'master' : 'slave';
+                       $from = ( $this->queryFlagsUsed & self::READ_LATEST ) ? 'master' : 'replica';
                        throw new MWException(
                                "CAS update failed on user_touched for user ID '{$this->mId}' (read from $from);" .
                                " the version of the user to be saved is older than the current version."
@@ -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 slave server, the count is
+                               // 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++;
@@ -4947,9 +4947,9 @@ class User implements IDBAccessObject {
         * @return int Number of edits
         */
        protected function initEditCount( $add = 0 ) {
-               // Pull from a slave to be less cruel to servers
+               // 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',
@@ -5317,7 +5317,7 @@ class User implements IDBAccessObject {
         * Get a new instance of this user that was loaded from the master via a locking read
         *
         * Use this instead of the main context User when updating that user. This avoids races
-        * where that user was loaded from a slave or even the master but without proper locks.
+        * where that user was loaded from a replica DB or even the master but without proper locks.
         *
         * @return User|null Returns null if the user was not found in the DB
         * @since 1.27
index a4d4356..dddc850 100644 (file)
@@ -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(),
index 4a27a13..b7d5058 100644 (file)
@@ -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() ) ];
index 549ad41..1e7eda8 100644 (file)
@@ -4,7 +4,7 @@
  * method of batch updating rows in a database. To use create a class
  * implementing the RowUpdateGenerator interface and configure the
  * BatchRowIterator and BatchRowWriter for access to the correct table.
- * The components will handle reading, writing, and waiting for slaves
+ * The components will handle reading, writing, and waiting for replica DBs
  * while the generator implementation handles generating update arrays
  * for singular rows.
  *
index 698fd9a..6e1f741 100644 (file)
@@ -109,7 +109,7 @@ abstract class Maintenance {
        private $mDb = null;
 
        /** @var float UNIX timestamp */
-       private $lastSlaveWait = 0.0;
+       private $lastReplicationWait = 0.0;
 
        /**
         * Used when creating separate schema files.
@@ -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
@@ -1264,23 +1264,29 @@ abstract class Maintenance {
        }
 
        /**
-        * Commit the transcation on a DB handle and wait for slaves to catch up
+        * Commit the transcation on a DB handle and wait for replica DBs to catch up
         *
         * This method makes it clear that commit() is called from a maintenance script,
         * which has outermost scope. This is safe, unlike $dbw->commit() called in other places.
         *
         * @param IDatabase $dbw
         * @param string $fname Caller name
-        * @return bool Whether the slave wait succeeded
+        * @return bool Whether the replica DB wait succeeded
         * @since 1.27
         */
        protected function commitTransaction( IDatabase $dbw, $fname ) {
                $dbw->commit( $fname );
+               try {
+                       $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
+                       $lbFactory->waitForReplication(
+                               [ 'timeout' => 30, 'ifWritesSince' => $this->lastReplicationWait ]
+                       );
+                       $this->lastReplicationWait = microtime( true );
 
-               $ok = wfWaitForSlaves( $this->lastSlaveWait, false, '*', 30 );
-               $this->lastSlaveWait = microtime( true );
-
-               return $ok;
+                       return true;
+               } catch ( DBReplicationWaitError $e ) {
+                       return false;
+               }
        }
 
        /**
index db3af92..38daf64 100644 (file)
@@ -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.
index 0a89bfa..884e307 100644 (file)
@@ -118,7 +118,7 @@ class BenchmarkParse extends Maintenance {
         * @return bool|string Revision ID, or false if not found or error
         */
        function getRevIdForTime( Title $title, $timestamp ) {
-               $dbr = $this->getDB( DB_SLAVE );
+               $dbr = $this->getDB( DB_REPLICA );
 
                $id = $dbr->selectField(
                        [ 'revision', 'page' ],
index 097ad1f..6eafc96 100644 (file)
@@ -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' ],
index f05d15c..3e57393 100644 (file)
@@ -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;
index 6c66da4..e6d9547 100644 (file)
@@ -40,7 +40,7 @@ class CheckUsernames extends Maintenance {
        }
 
        function execute() {
-               $dbr = $this->getDB( DB_SLAVE );
+               $dbr = $this->getDB( DB_REPLICA );
 
                $maxUserId = 0;
                do {
index 2f3f013..4e47cfb 100644 (file)
@@ -64,7 +64,7 @@ class CleanupSpam extends Maintenance {
                        $this->output( "Finding spam on " . count( $wgLocalDatabases ) . " wikis\n" );
                        $found = false;
                        foreach ( $wgLocalDatabases as $wikiID ) {
-                               $dbr = $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 );
index a18b81e..3ace09c 100644 (file)
@@ -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' ] )
index 4f23ef0..650fae0 100644 (file)
@@ -78,7 +78,7 @@ class TitleCleanup extends TableCleanup {
        protected function fileExists( $name ) {
                // XXX: Doesn't actually check for file existence, just presence of image record.
                // This is reasonable, since cleanupImages.php only iterates over the image table.
-               $dbr = $this->getDB( DB_SLAVE );
+               $dbr = $this->getDB( DB_REPLICA );
                $row = $dbr->selectRow( 'image', [ 'img_name' ], [ 'img_name' => $name ], __METHOD__ );
 
                return $row !== false;
index 13b239f..ce19974 100644 (file)
@@ -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 ) {
index 245b613..8bd060f 100644 (file)
@@ -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;
index 35a7ca7..69f4f89 100644 (file)
@@ -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' ],
                        [
index 1faeb8a..ff4e894 100644 (file)
@@ -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',
index cfb59c6..d0bda4e 100644 (file)
@@ -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() . ")" );
index 5b446d8..8d63fe5 100644 (file)
@@ -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' ],
                        '',
index 7e1b527..2ed1efa 100644 (file)
@@ -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 );
index 232151b..460b553 100644 (file)
@@ -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' ),
index 0592d2d..1d6f31d 100644 (file)
@@ -54,7 +54,7 @@ class FixDoubleRedirects extends Maintenance {
                        $title = null;
                }
 
-               $dbr = $this->getDB( DB_SLAVE );
+               $dbr = $this->getDB( DB_REPLICA );
 
                // See also SpecialDoubleRedirects
                $tables = [
index f4674cb..37fd44f 100644 (file)
@@ -80,7 +80,7 @@ class FixUserRegistration extends Maintenance {
                                        $this->output( "Could not find registration for #$id NULL\n" );
                                }
                        }
-                       $this->output( "Waiting for slaves..." );
+                       $this->output( "Waiting for replica DBs..." );
                        wfWaitForSlaves();
                        $this->output( " done.\n" );
                } while ( $res->numRows() >= $this->mBatchSize );
index f5cc6f6..87af5b8 100644 (file)
@@ -113,7 +113,7 @@ class GenerateSitemap extends Maintenance {
        public $timestamp;
 
        /**
-        * A database slave object
+        * A database replica DB object
         *
         * @var object
         */
@@ -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
new file mode 100644 (file)
index 0000000..6e0a1fe
--- /dev/null
@@ -0,0 +1,55 @@
+<?php
+/**
+ * Reports the hostname of a replica DB server.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @ingroup Maintenance
+ */
+
+require_once __DIR__ . '/Maintenance.php';
+
+/**
+ * Maintenance script that reports the hostname of a replica DB server.
+ *
+ * @ingroup Maintenance
+ */
+class GetSlaveServer extends Maintenance {
+       public function __construct() {
+               parent::__construct();
+               $this->addOption( "group", "Query group to check specifically" );
+               $this->addDescription( 'Report the hostname of a replica DB server' );
+       }
+
+       public function execute() {
+               global $wgAllDBsAreLocalhost;
+               if ( $wgAllDBsAreLocalhost ) {
+                       $host = 'localhost';
+               } elseif ( $this->hasOption( 'group' ) ) {
+                       $db = $this->getDB( DB_REPLICA, $this->getOption( 'group' ) );
+                       $host = $db->getServer();
+               } else {
+                       $lb = wfGetLB();
+                       $i = $lb->getReaderIndex();
+                       $host = $lb->getServerName( $i );
+               }
+               $this->output( "$host\n" );
+       }
+}
+
+$maintClass = "GetSlaveServer";
+require_once RUN_MAINTENANCE_IF_MAIN;
index 81228cc..2160928 100644 (file)
@@ -1,55 +1,3 @@
 <?php
-/**
- * Reports the hostname of a slave server.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- * @file
- * @ingroup Maintenance
- */
-
-require_once __DIR__ . '/Maintenance.php';
-
-/**
- * Maintenance script that reports the hostname of a slave server.
- *
- * @ingroup Maintenance
- */
-class GetSlaveServer extends Maintenance {
-       public function __construct() {
-               parent::__construct();
-               $this->addOption( "group", "Query group to check specifically" );
-               $this->addDescription( 'Report the hostname of a slave server' );
-       }
-
-       public function execute() {
-               global $wgAllDBsAreLocalhost;
-               if ( $wgAllDBsAreLocalhost ) {
-                       $host = 'localhost';
-               } elseif ( $this->hasOption( 'group' ) ) {
-                       $db = $this->getDB( DB_SLAVE, $this->getOption( 'group' ) );
-                       $host = $db->getServer();
-               } else {
-                       $lb = wfGetLB();
-                       $i = $lb->getReaderIndex();
-                       $host = $lb->getServerName( $i );
-               }
-               $this->output( "$host\n" );
-       }
-}
-
-$maintClass = "GetSlaveServer";
-require_once RUN_MAINTENANCE_IF_MAIN;
+// B/C alias
+require_once ( __DIR__ . '/getReplicaServer.php' );
index c653a5f..ac700ef 100644 (file)
@@ -297,8 +297,8 @@ if ( $count > 0 ) {
 
                        if ( $doProtect ) {
                                # Protect the file
-                               echo "\nWaiting for slaves...\n";
-                               // Wait for slaves.
+                               echo "\nWaiting for replica DBs...\n";
+                               // Wait for replica DBs.
                                sleep( 2.0 ); # Why this sleep?
                                wfWaitForSlaves();
 
index 50a4018..6b06da7 100644 (file)
@@ -29,8 +29,8 @@ class InitEditCount extends Maintenance {
                parent::__construct();
                $this->addOption( 'quick', 'Force the update to be done in a single query' );
                $this->addOption( 'background', 'Force replication-friendly mode; may be inefficient but
-               avoids locking tables or lagging slaves with large updates;
-               calculates counts on a slave if possible.
+               avoids locking tables or lagging replica DBs with large updates;
+               calculates counts on a replica DB if possible.
 
 Background mode will be automatically used if multiple servers are listed
 in the load balancer, usually indicating a replication environment.' );
@@ -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__ );
 
index 942f3f2..7557a42 100644 (file)
@@ -91,7 +91,7 @@ class PopulateFilearchiveSha1 extends LoggedUpdateMaintenance {
                                break;
                        }
 
-                       // print status and let slaves catch up
+                       // print status and let replica DBs catch up
                        $this->output( sprintf(
                                "id %d done (up to %d), %5.3f%%  \r", $lastId, $endId, $lastId / $endId * 100 ) );
                        wfWaitForSlaves();
index dcb9933..5e44faf 100644 (file)
@@ -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__ );
index 70a26cb..615d1fe 100644 (file)
@@ -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" );
index 58a4640..b354399 100644 (file)
@@ -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' ) );
 
index 21d1169..5ca7918 100644 (file)
@@ -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 = [];
index 38556ed..649557e 100644 (file)
@@ -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
index f67739b..3157186 100644 (file)
@@ -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 );
index d2ee6fc..95822ca 100644 (file)
@@ -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' );
index ea5b6f9..e075501 100644 (file)
@@ -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 ) ) {
index 95a49d6..24c8c11 100644 (file)
@@ -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',
index 0f67317..1034005 100644 (file)
@@ -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 {
index e3c99ed..ec8fcfe 100644 (file)
@@ -45,7 +45,7 @@ class RemoveUnusedAccounts extends Maintenance {
                # Do an initial scan for inactive accounts and report the result
                $this->output( "Checking for unused user accounts...\n" );
                $del = [];
-               $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',
index 131a569..481da98 100644 (file)
@@ -67,8 +67,9 @@ class ResetUserTokens extends Maintenance {
                        wfCountDown( 5 );
                }
 
+               // We list user by user_id from one of the replica DBs
                // We list user by user_id from one of the slave database
-               $dbr = $this->getDB( DB_SLAVE );
+               $dbr = $this->getDB( DB_REPLICA );
 
                $where = [];
                if ( $this->nullsOnly ) {
index 10c107e..5ad7d4e 100644 (file)
@@ -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' ],
index 2feae02..a5e7a2f 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * Run a database query in batches and wait for slaves. This is used on large
+ * Run a database query in batches and wait for replica DBs. This is used on large
  * wikis to prevent replication lag from going through the roof when executing
  * large write queries.
  *
@@ -26,7 +26,7 @@
 require_once __DIR__ . '/Maintenance.php';
 
 /**
- * Maintenance script to run a database query in batches and wait for slaves.
+ * Maintenance script to run a database query in batches and wait for replica DBs.
  *
  * @ingroup Maintenance
  */
@@ -34,7 +34,7 @@ class BatchedQueryRunner extends Maintenance {
        public function __construct() {
                parent::__construct();
                $this->addDescription(
-                       "Run a query repeatedly until it affects 0 rows, and wait for slaves in between.\n" .
+                       "Run a query repeatedly until it affects 0 rows, and wait for replica DBs in between.\n" .
                                "NOTE: You need to set a LIMIT clause yourself." );
        }
 
index 1d3e43a..5a15165 100644 (file)
@@ -52,8 +52,8 @@ class ShowSiteStats extends Maintenance {
                        'ss_images' => 'Number of images',
                ];
 
-               // Get cached stats from slave database
-               $dbr = $this->getDB( DB_SLAVE );
+               // Get cached stats from a replica DB
+               $dbr = $this->getDB( DB_REPLICA );
                $stats = $dbr->selectRow( 'site_stats', '*', '', __METHOD__ );
 
                // Get maximum size for each column
index 1aceace..e6a30a3 100644 (file)
@@ -34,10 +34,13 @@ class MwSql extends Maintenance {
                parent::__construct();
                $this->addDescription( 'Send SQL queries to a MediaWiki database. ' .
                        'Takes a file name containing SQL as argument or runs interactively.' );
-               $this->addOption( 'query', 'Run a single query instead of running interactively', false, true );
+               $this->addOption( 'query',
+                       'Run a single query instead of running interactively', false, true );
                $this->addOption( 'cluster', 'Use an external cluster by name', false, true );
-               $this->addOption( 'wikidb', 'The database wiki ID to use if not the current one', false, true );
-               $this->addOption( 'slave', 'Use a slave server (either "any" or by name)', false, true );
+               $this->addOption( 'wikidb',
+                       'The database wiki ID to use if not the current one', false, true );
+               $this->addOption( 'replicadb',
+                       'Replica DB server to use instead of the master DB (can be "any")', false, true );
        }
 
        public function execute() {
@@ -50,30 +53,28 @@ class MwSql extends Maintenance {
                        $lb = wfGetLB( $wiki );
                }
                // Figure out which server to use
-               if ( $this->hasOption( 'slave' ) ) {
-                       $server = $this->getOption( 'slave' );
-                       if ( $server === 'any' ) {
-                               $index = DB_SLAVE;
-                       } else {
-                               $index = null;
-                               $serverCount = $lb->getServerCount();
-                               for ( $i = 0; $i < $serverCount; ++$i ) {
-                                       if ( $lb->getServerName( $i ) === $server ) {
-                                               $index = $i;
-                                               break;
-                                       }
-                               }
-                               if ( $index === null ) {
-                                       $this->error( "No slave server configured with the name '$server'.", 1 );
+               $replicaDB = $this->getOption( 'replicadb', $this->getOption( 'slave', '' ) );
+               if ( $replicaDB === 'any' ) {
+                       $index = DB_REPLICA;
+               } elseif ( $replicaDB != '' ) {
+                       $index = null;
+                       $serverCount = $lb->getServerCount();
+                       for ( $i = 0; $i < $serverCount; ++$i ) {
+                               if ( $lb->getServerName( $i ) === $replicaDB ) {
+                                       $index = $i;
+                                       break;
                                }
                        }
+                       if ( $index === null ) {
+                               $this->error( "No replica DB server configured with the name '$server'.", 1 );
+                       }
                } else {
                        $index = DB_MASTER;
                }
                // Get a DB handle (with this wiki's DB selected) from the appropriate load balancer
                $db = $lb->getConnection( $index, [], $wiki );
-               if ( $this->hasOption( 'slave' ) && $db->getLBInfo( 'master' ) !== null ) {
-                       $this->error( "The server selected ({$db->getServer()}) is not a slave.", 1 );
+               if ( $replicaDB != '' && $db->getLBInfo( 'master' ) !== null ) {
+                       $this->error( "The server selected ({$db->getServer()}) is not a replica DB.", 1 );
                }
 
                if ( $this->hasArg( 0 ) ) {
index d69e5b9..bb9f4ea 100644 (file)
@@ -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";
index ba924bf..289d22d 100644 (file)
@@ -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
index 39e06a3..437bfcd 100644 (file)
@@ -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' ],
index 94335cf..b444f31 100644 (file)
@@ -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' ],
index 80dc7f9..e117992 100644 (file)
@@ -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;
index d775830..d7d0b84 100644 (file)
@@ -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 );
                }
index 292a25d..a0efcb8 100644 (file)
@@ -23,6 +23,7 @@
  */
 
 use MediaWiki\Logger\LegacyLogger;
+use MediaWiki\MediaWikiServices;
 
 $optionsWithArgs = RecompressTracked::getOptionsWithArgs();
 require __DIR__ . '/../commandLine.inc';
@@ -60,17 +61,17 @@ class RecompressTracked {
        public $numProcs = 1;
        public $numBatches = 0;
        public $pageBlobClass, $orphanBlobClass;
-       public $slavePipes, $slaveProcs, $prevSlaveId;
+       public $replicaPipes, $replicaProcs, $prevReplicaId;
        public $copyOnly = false;
        public $isChild = false;
-       public $slaveId = false;
+       public $replicaId = false;
        public $noCount = false;
        public $debugLog, $infoLog, $criticalLog;
        public $store;
 
        private static $optionsWithArgs = [
                'procs',
-               'slave-id',
+               'replica-id',
                'debug-log',
                'info-log',
                'critical-log'
@@ -81,7 +82,7 @@ class RecompressTracked {
                'procs' => 'numProcs',
                'copy-only' => 'copyOnly',
                'child' => 'isChild',
-               'slave-id' => 'slaveId',
+               'replica-id' => 'replicaId',
                'debug-log' => 'debugLog',
                'info-log' => 'infoLog',
                'critical-log' => 'criticalLog',
@@ -109,8 +110,8 @@ class RecompressTracked {
                $this->store = new ExternalStoreDB;
                if ( !$this->isChild ) {
                        $GLOBALS['wgDebugLogPrefix'] = "RCT M: ";
-               } elseif ( $this->slaveId !== false ) {
-                       $GLOBALS['wgDebugLogPrefix'] = "RCT {$this->slaveId}: ";
+               } elseif ( $this->replicaId !== false ) {
+                       $GLOBALS['wgDebugLogPrefix'] = "RCT {$this->replicaId}: ";
                }
                $this->pageBlobClass = function_exists( 'xdiff_string_bdiff' ) ?
                        'DiffHistoryBlob' : 'ConcatenatedGzipHistoryBlob';
@@ -140,21 +141,21 @@ class RecompressTracked {
 
        function logToFile( $msg, $file ) {
                $header = '[' . date( 'd\TH:i:s' ) . '] ' . wfHostname() . ' ' . posix_getpid();
-               if ( $this->slaveId !== false ) {
-                       $header .= "({$this->slaveId})";
+               if ( $this->replicaId !== false ) {
+                       $header .= "({$this->replicaId})";
                }
                $header .= ' ' . wfWikiID();
                LegacyLogger::emit( sprintf( "%-50s %s\n", $header, $msg ), $file );
        }
 
        /**
-        * Wait until the selected slave has caught up to the master.
-        * This allows us to use the slave for things that were committed in a
+        * Wait until the selected replica DB has caught up to the master.
+        * This allows us to use the replica DB for things that were committed in a
         * previous part of this batch process.
         */
        function syncDBs() {
                $dbw = wfGetDB( DB_MASTER );
-               $dbr = wfGetDB( DB_SLAVE );
+               $dbr = wfGetDB( DB_REPLICA );
                $pos = $dbw->getMasterPos();
                $dbr->masterPosWait( $pos, 100000 );
        }
@@ -179,10 +180,10 @@ class RecompressTracked {
                }
 
                $this->syncDBs();
-               $this->startSlaveProcs();
+               $this->startReplicaProcs();
                $this->doAllPages();
                $this->doAllOrphans();
-               $this->killSlaveProcs();
+               $this->killReplicaProcs();
        }
 
        /**
@@ -190,7 +191,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" );
 
@@ -212,10 +213,10 @@ class RecompressTracked {
         * This necessary because text recompression is slow: loading, compressing and
         * writing are all slow.
         */
-       function startSlaveProcs() {
+       function startReplicaProcs() {
                $cmd = 'php ' . wfEscapeShellArg( __FILE__ );
                foreach ( self::$cmdLineOptionMap as $cmdOption => $classOption ) {
-                       if ( $cmdOption == 'slave-id' ) {
+                       if ( $cmdOption == 'replica-id' ) {
                                continue;
                        } elseif ( in_array( $cmdOption, self::$optionsWithArgs ) && isset( $this->$classOption ) ) {
                                $cmd .= " --$cmdOption " . wfEscapeShellArg( $this->$classOption );
@@ -227,7 +228,7 @@ class RecompressTracked {
                        ' --wiki ' . wfEscapeShellArg( wfWikiID() ) .
                        ' ' . call_user_func_array( 'wfEscapeShellArg', $this->destClusters );
 
-               $this->slavePipes = $this->slaveProcs = [];
+               $this->replicaPipes = $this->replicaProcs = [];
                for ( $i = 0; $i < $this->numProcs; $i++ ) {
                        $pipes = [];
                        $spec = [
@@ -236,28 +237,28 @@ class RecompressTracked {
                                [ 'file', 'php://stderr', 'w' ]
                        ];
                        MediaWiki\suppressWarnings();
-                       $proc = proc_open( "$cmd --slave-id $i", $spec, $pipes );
+                       $proc = proc_open( "$cmd --replica-id $i", $spec, $pipes );
                        MediaWiki\restoreWarnings();
                        if ( !$proc ) {
-                               $this->critical( "Error opening slave process: $cmd" );
+                               $this->critical( "Error opening replica DB process: $cmd" );
                                exit( 1 );
                        }
-                       $this->slaveProcs[$i] = $proc;
-                       $this->slavePipes[$i] = $pipes[0];
+                       $this->replicaProcs[$i] = $proc;
+                       $this->replicaPipes[$i] = $pipes[0];
                }
-               $this->prevSlaveId = -1;
+               $this->prevReplicaId = -1;
        }
 
        /**
         * Gracefully terminate the child processes
         */
-       function killSlaveProcs() {
-               $this->info( "Waiting for slave processes to finish..." );
+       function killReplicaProcs() {
+               $this->info( "Waiting for replica DB processes to finish..." );
                for ( $i = 0; $i < $this->numProcs; $i++ ) {
-                       $this->dispatchToSlave( $i, 'quit' );
+                       $this->dispatchToReplica( $i, 'quit' );
                }
                for ( $i = 0; $i < $this->numProcs; $i++ ) {
-                       $status = proc_close( $this->slaveProcs[$i] );
+                       $status = proc_close( $this->replicaProcs[$i] );
                        if ( $status ) {
                                $this->critical( "Warning: child #$i exited with status $status" );
                        }
@@ -266,22 +267,22 @@ class RecompressTracked {
        }
 
        /**
-        * Dispatch a command to the next available slave.
-        * This may block until a slave finishes its work and becomes available.
+        * Dispatch a command to the next available replica DB.
+        * This may block until a replica DB finishes its work and becomes available.
         */
        function dispatch( /*...*/ ) {
                $args = func_get_args();
-               $pipes = $this->slavePipes;
+               $pipes = $this->replicaPipes;
                $numPipes = stream_select( $x = [], $pipes, $y = [], 3600 );
                if ( !$numPipes ) {
-                       $this->critical( "Error waiting to write to slaves. Aborting" );
+                       $this->critical( "Error waiting to write to replica DBs. Aborting" );
                        exit( 1 );
                }
                for ( $i = 0; $i < $this->numProcs; $i++ ) {
-                       $slaveId = ( $i + $this->prevSlaveId + 1 ) % $this->numProcs;
-                       if ( isset( $pipes[$slaveId] ) ) {
-                               $this->prevSlaveId = $slaveId;
-                               $this->dispatchToSlave( $slaveId, $args );
+                       $replicaId = ( $i + $this->prevReplicaId + 1 ) % $this->numProcs;
+                       if ( isset( $pipes[$replicaId] ) ) {
+                               $this->prevReplicaId = $replicaId;
+                               $this->dispatchToReplica( $replicaId, $args );
 
                                return;
                        }
@@ -291,21 +292,21 @@ class RecompressTracked {
        }
 
        /**
-        * Dispatch a command to a specified slave
-        * @param int $slaveId
+        * Dispatch a command to a specified replica DB
+        * @param int $replicaId
         * @param array|string $args
         */
-       function dispatchToSlave( $slaveId, $args ) {
+       function dispatchToReplica( $replicaId, $args ) {
                $args = (array)$args;
                $cmd = implode( ' ', $args );
-               fwrite( $this->slavePipes[$slaveId], "$cmd\n" );
+               fwrite( $this->replicaPipes[$replicaId], "$cmd\n" );
        }
 
        /**
         * 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 ) {
@@ -366,7 +367,7 @@ class RecompressTracked {
                if ( $current == $end || $this->numBatches >= $this->reportingInterval ) {
                        $this->numBatches = 0;
                        $this->info( "$label: $current / $end" );
-                       wfWaitForSlaves();
+                       MediaWikiServices::getInstance()->getDBLoadBalancerFactory()->waitForReplication();
                }
        }
 
@@ -374,7 +375,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 ) {
@@ -464,7 +465,7 @@ class RecompressTracked {
                                case 'quit':
                                        return;
                        }
-                       wfWaitForSlaves();
+                       MediaWikiServices::getInstance()->getDBLoadBalancerFactory()->waitForReplication();
                }
        }
 
@@ -480,7 +481,7 @@ class RecompressTracked {
                } else {
                        $titleText = '[deleted]';
                }
-               $dbr = wfGetDB( DB_SLAVE );
+               $dbr = wfGetDB( DB_REPLICA );
 
                // Finish any incomplete transactions
                if ( !$this->copyOnly ) {
@@ -491,6 +492,7 @@ class RecompressTracked {
                $startId = 0;
                $trx = new CgzCopyTransaction( $this, $this->pageBlobClass );
 
+               $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
                while ( true ) {
                        $res = $dbr->select(
                                [ 'blob_tracking', 'text' ],
@@ -532,7 +534,7 @@ class RecompressTracked {
                                        $this->debug( "$titleText: committing blob with " . $trx->getSize() . " items" );
                                        $trx->commit();
                                        $trx = new CgzCopyTransaction( $this, $this->pageBlobClass );
-                                       wfWaitForSlaves();
+                                       $lbFactory->waitForReplication();
                                }
                        }
                }
@@ -590,7 +592,8 @@ class RecompressTracked {
         * @param array $conds
         */
        function finishIncompleteMoves( $conds ) {
-               $dbr = wfGetDB( DB_SLAVE );
+               $dbr = wfGetDB( DB_REPLICA );
+               $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
 
                $startId = 0;
                $conds = array_merge( $conds, [
@@ -615,7 +618,7 @@ class RecompressTracked {
                                $startId = $row->bt_text_id;
                                $this->moveTextRow( $row->bt_text_id, $row->bt_new_url );
                                if ( $row->bt_text_id % 10 == 0 ) {
-                                       wfWaitForSlaves();
+                                       $lbFactory->waitForReplication();
                                }
                        }
                }
@@ -659,7 +662,8 @@ class RecompressTracked {
 
                $trx = new CgzCopyTransaction( $this, $this->orphanBlobClass );
 
-               $res = wfGetDB( DB_SLAVE )->select(
+               $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
+               $res = wfGetDB( DB_REPLICA )->select(
                        [ 'text', 'blob_tracking' ],
                        [ 'old_id', 'old_text', 'old_flags' ],
                        [
@@ -682,7 +686,7 @@ class RecompressTracked {
                                $this->debug( "[orphan]: committing blob with " . $trx->getSize() . " rows" );
                                $trx->commit();
                                $trx = new CgzCopyTransaction( $this, $this->orphanBlobClass );
-                               wfWaitForSlaves();
+                               $lbFactory->waitForReplication();
                        }
                }
                $this->debug( "[orphan]: committing blob with " . $trx->getSize() . " rows" );
@@ -762,7 +766,7 @@ class CgzCopyTransaction {
 
                /* Check to see if the target text_ids have been moved already.
                 *
-                * We originally read from the slave, so this can happen when a single
+                * We originally read from the replica DB, so this can happen when a single
                 * text_id is shared between multiple pages. It's rare, but possible
                 * if a delete/move/undelete cycle splits up a null edit.
                 *
index 33a9f96..8ca8bb2 100644 (file)
@@ -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' ) {
index 04d2557..c23f508 100644 (file)
@@ -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 ) {
index 2692a07..90d8d03 100644 (file)
@@ -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' ],
        '*',
index 214f5b1..a2dc376 100644 (file)
@@ -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;
@@ -219,9 +219,9 @@ class TrackBlobs {
         * archive table counts as orphan for our purposes.
         */
        function trackOrphanText() {
-               # Wait until the blob_tracking table is available in the slave
+               # 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";
index f47e13c..9d7cc0e 100644 (file)
@@ -7,7 +7,7 @@ require_once __DIR__ . '/Maintenance.php';
 class TidyUpBug37714 extends Maintenance {
        public function execute() {
                // Search for all log entries which are about changing the visability of other log entries.
-               $result = $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 ],
index dff5aec..213195d 100644 (file)
@@ -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();
index 930f533..e754e3c 100644 (file)
@@ -34,7 +34,7 @@ require_once __DIR__ . '/Maintenance.php';
  */
 class UpdateCollation extends Maintenance {
        const BATCH_SIZE = 100; // Number of rows to process in one batch
-       const SYNC_INTERVAL = 5; // Wait for slaves after this many batches
+       const SYNC_INTERVAL = 5; // Wait for replica DBs after this many batches
 
        public $sizeHistogram = [];
 
@@ -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' );
@@ -224,7 +224,7 @@ TEXT
                        $this->output( "$count done.\n" );
 
                        if ( !$dryRun && ++$batchCount % self::SYNC_INTERVAL == 0 ) {
-                               $this->output( "Waiting for slaves ... " );
+                               $this->output( "Waiting for replica DBs ... " );
                                wfWaitForSlaves();
                                $this->output( "done\n" );
                        }
index 8b24b90..5ea3828 100644 (file)
@@ -109,7 +109,7 @@ class UpdateSpecialPages extends Maintenance {
                                                } while ( !wfGetLB()->pingAll() );
                                                $this->output( "Reconnected\n\n" );
                                        }
-                                       # Wait for the slave to catch up
+                                       # Wait for the replica DB to catch up
                                        wfWaitForSlaves();
                                } else {
                                        $this->output( "cheap, skipped\n" );
@@ -153,7 +153,7 @@ class UpdateSpecialPages extends Maintenance {
                                        $this->output( $minutes . 'm ' );
                                }
                                $this->output( sprintf( "%.2fs\n", $seconds ) );
-                               # Wait for the slave to catch up
+                               # Wait for the replica DB to catch up
                                wfWaitForSlaves();
                        }
                }
index 4b0a817..c657c03 100644 (file)
@@ -140,8 +140,8 @@ class UserOptions {
                $ret = [];
                $defaultOptions = User::getDefaultOptions();
 
-               // We list user by user_id from one of the slave database
-               $dbr = wfGetDB( DB_SLAVE );
+               // We list user by user_id from one of the replica DBs
+               $dbr = wfGetDB( DB_REPLICA );
                $result = $dbr->select( 'user',
                        [ 'user_id' ],
                        [],
@@ -194,8 +194,8 @@ class UserOptions {
        private function CHANGER() {
                $this->warn();
 
-               // We list user by user_id from one of the slave database
-               $dbr = wfGetDB( DB_SLAVE );
+               // We list user by user_id from one of the replica DBs
+               $dbr = wfGetDB( DB_REPLICA );
                $result = $dbr->select( 'user',
                        [ 'user_id' ],
                        [],
index 8ca7203..7055f36 100644 (file)
@@ -989,6 +989,16 @@ return [
                // must be loaded on the bottom
                'position' => 'bottom',
        ],
+       'mediawiki.diff.styles' => [
+               'position' => 'top',
+               'styles' => [
+                       'resources/src/mediawiki/mediawiki.diff.styles.css',
+                       'resources/src/mediawiki/mediawiki.diff.styles.print.css' => [
+                               'media' => 'print'
+                       ],
+               ],
+               'targets' => [ 'desktop', 'mobile' ],
+       ],
        'mediawiki.feedback' => [
                'scripts' => 'resources/src/mediawiki/mediawiki.feedback.js',
                'styles' => 'resources/src/mediawiki/mediawiki.feedback.css',
@@ -1484,7 +1494,7 @@ return [
                        'jquery.spinner',
                        'jquery.textSelection',
                        'mediawiki.api',
-                       'mediawiki.action.history.diff',
+                       'mediawiki.diff.styles',
                        'mediawiki.util',
                        'mediawiki.jqueryMsg',
                ],
@@ -1511,11 +1521,12 @@ return [
                'position' => 'top',
                'styles' => 'resources/src/mediawiki.action/mediawiki.action.history.styles.css',
        ],
+       // using this module is deprecated, for diff styles use mediawiki.diff.styles instead
        'mediawiki.action.history.diff' => [
                'position' => 'top',
                'styles' => [
-                       'resources/src/mediawiki.action/mediawiki.action.history.diff.css',
-                       'resources/src/mediawiki.action/mediawiki.action.history.diff.print.css' => [
+                       'resources/src/mediawiki/mediawiki.diff.styles.css',
+                       'resources/src/mediawiki/mediawiki.diff.styles.print.css' => [
                                'media' => 'print'
                        ],
                ],
diff --git a/resources/src/mediawiki.action/mediawiki.action.history.diff.css b/resources/src/mediawiki.action/mediawiki.action.history.diff.css
deleted file mode 100644 (file)
index 327c9c8..0000000
+++ /dev/null
@@ -1,120 +0,0 @@
-/*!
- * Diff rendering
- */
-table.diff {
-       border: none;
-       border-spacing: 4px;
-       margin: 0;
-       width: 100%;
-       /* Ensure that colums are of equal width */
-       table-layout: fixed;
-}
-
-table.diff td {
-       padding: 0.33em 0.5em;
-}
-
-table.diff td.diff-marker {
-       /* Compensate padding for increased font-size */
-       padding: 0.25em;
-}
-
-table.diff col.diff-marker {
-       width: 2%;
-}
-
-table.diff col.diff-content {
-       width: 48%;
-}
-
-table.diff td div {
-       /* Force-wrap very long lines such as URLs or page-widening char strings */
-       word-wrap: break-word;
-}
-
-td.diff-otitle,
-td.diff-ntitle {
-       text-align: center;
-}
-
-td.diff-lineno {
-       font-weight: bold;
-}
-
-td.diff-marker {
-       text-align: right;
-       font-weight: bold;
-       font-size: 1.25em;
-       line-height: 1.2;
-}
-
-td.diff-addedline,
-td.diff-deletedline,
-td.diff-context {
-       font-size: 88%;
-       line-height: 1.6;
-       vertical-align: top;
-       white-space: -moz-pre-wrap;
-       white-space: pre-wrap;
-       border-style: solid;
-       border-width: 1px 1px 1px 4px;
-       border-radius: 0.33em;
-}
-
-td.diff-addedline {
-       border-color: #a3d3ff;
-}
-
-td.diff-deletedline {
-       border-color: #ffe49c;
-}
-
-td.diff-context {
-       background: #f9f9f9;
-       border-color: #e6e6e6;
-       color: #333;
-}
-
-.diffchange {
-       font-weight: bold;
-       text-decoration: none;
-}
-
-td.diff-addedline .diffchange,
-td.diff-deletedline .diffchange {
-       border-radius: 0.33em;
-       padding: 0.25em 0;
-}
-
-td.diff-addedline .diffchange {
-       background: #d8ecff;
-}
-
-td.diff-deletedline .diffchange {
-       background: #feeec8;
-}
-
-/* Correct user & content directionality when viewing a diff */
-.diff-currentversion-title,
-.diff {
-       direction: ltr;
-       unicode-bidi: embed;
-}
-
-/* @noflip */ .diff-contentalign-right td {
-       direction: rtl;
-       unicode-bidi: embed;
-}
-
-/* @noflip */ .diff-contentalign-left td {
-       direction: ltr;
-       unicode-bidi: embed;
-}
-
-.diff-multi,
-.diff-otitle,
-.diff-ntitle,
-.diff-lineno {
-       direction: ltr !important;
-       unicode-bidi: embed;
-}
diff --git a/resources/src/mediawiki.action/mediawiki.action.history.diff.print.css b/resources/src/mediawiki.action/mediawiki.action.history.diff.print.css
deleted file mode 100644 (file)
index 76b5c9b..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-/*!
- * Diff rendering
- */
-td.diff-context,
-td.diff-addedline .diffchange,
-td.diff-deletedline .diffchange {
-       background-color: transparent;
-}
-
-td.diff-addedline .diffchange {
-       text-decoration: underline;
-}
-
-td.diff-deletedline .diffchange {
-       text-decoration: line-through;
-}
diff --git a/resources/src/mediawiki/mediawiki.diff.styles.css b/resources/src/mediawiki/mediawiki.diff.styles.css
new file mode 100644 (file)
index 0000000..327c9c8
--- /dev/null
@@ -0,0 +1,120 @@
+/*!
+ * Diff rendering
+ */
+table.diff {
+       border: none;
+       border-spacing: 4px;
+       margin: 0;
+       width: 100%;
+       /* Ensure that colums are of equal width */
+       table-layout: fixed;
+}
+
+table.diff td {
+       padding: 0.33em 0.5em;
+}
+
+table.diff td.diff-marker {
+       /* Compensate padding for increased font-size */
+       padding: 0.25em;
+}
+
+table.diff col.diff-marker {
+       width: 2%;
+}
+
+table.diff col.diff-content {
+       width: 48%;
+}
+
+table.diff td div {
+       /* Force-wrap very long lines such as URLs or page-widening char strings */
+       word-wrap: break-word;
+}
+
+td.diff-otitle,
+td.diff-ntitle {
+       text-align: center;
+}
+
+td.diff-lineno {
+       font-weight: bold;
+}
+
+td.diff-marker {
+       text-align: right;
+       font-weight: bold;
+       font-size: 1.25em;
+       line-height: 1.2;
+}
+
+td.diff-addedline,
+td.diff-deletedline,
+td.diff-context {
+       font-size: 88%;
+       line-height: 1.6;
+       vertical-align: top;
+       white-space: -moz-pre-wrap;
+       white-space: pre-wrap;
+       border-style: solid;
+       border-width: 1px 1px 1px 4px;
+       border-radius: 0.33em;
+}
+
+td.diff-addedline {
+       border-color: #a3d3ff;
+}
+
+td.diff-deletedline {
+       border-color: #ffe49c;
+}
+
+td.diff-context {
+       background: #f9f9f9;
+       border-color: #e6e6e6;
+       color: #333;
+}
+
+.diffchange {
+       font-weight: bold;
+       text-decoration: none;
+}
+
+td.diff-addedline .diffchange,
+td.diff-deletedline .diffchange {
+       border-radius: 0.33em;
+       padding: 0.25em 0;
+}
+
+td.diff-addedline .diffchange {
+       background: #d8ecff;
+}
+
+td.diff-deletedline .diffchange {
+       background: #feeec8;
+}
+
+/* Correct user & content directionality when viewing a diff */
+.diff-currentversion-title,
+.diff {
+       direction: ltr;
+       unicode-bidi: embed;
+}
+
+/* @noflip */ .diff-contentalign-right td {
+       direction: rtl;
+       unicode-bidi: embed;
+}
+
+/* @noflip */ .diff-contentalign-left td {
+       direction: ltr;
+       unicode-bidi: embed;
+}
+
+.diff-multi,
+.diff-otitle,
+.diff-ntitle,
+.diff-lineno {
+       direction: ltr !important;
+       unicode-bidi: embed;
+}
diff --git a/resources/src/mediawiki/mediawiki.diff.styles.print.css b/resources/src/mediawiki/mediawiki.diff.styles.print.css
new file mode 100644 (file)
index 0000000..76b5c9b
--- /dev/null
@@ -0,0 +1,16 @@
+/*!
+ * Diff rendering
+ */
+td.diff-context,
+td.diff-addedline .diffchange,
+td.diff-deletedline .diffchange {
+       background-color: transparent;
+}
+
+td.diff-addedline .diffchange {
+       text-decoration: underline;
+}
+
+td.diff-deletedline .diffchange {
+       text-decoration: line-through;
+}
index 3562ed8..24c5d92 100644 (file)
@@ -107,7 +107,7 @@ class LBFactoryTest extends MediaWikiTestCase {
                        $wgDBserver, $dbw->getLBInfo( 'clusterMasterHost' ), 'cluster master set' );
 
                $dbr = $lb->getConnection( DB_SLAVE );
-               $this->assertTrue( $dbr->getLBInfo( 'slave' ), 'slave shows as slave' );
+               $this->assertTrue( $dbr->getLBInfo( 'replica' ), 'slave shows as slave' );
                $this->assertEquals(
                        $wgDBserver, $dbr->getLBInfo( 'clusterMasterHost' ), 'cluster master set' );
 
@@ -145,7 +145,7 @@ class LBFactoryTest extends MediaWikiTestCase {
                $this->assertTrue( $dbw->getLBInfo( 'master' ), 'master shows as master' );
 
                $dbr = $lb->getConnection( DB_SLAVE );
-               $this->assertTrue( $dbr->getLBInfo( 'slave' ), 'slave shows as slave' );
+               $this->assertTrue( $dbr->getLBInfo( 'replica' ), 'slave shows as slave' );
 
                $factory->shutdown();
                $lb->closeAll();