doc: Modernise parameter names and documentation for 'replica' DBs
authorJames D. Forrester <jforrester@wikimedia.org>
Wed, 31 Oct 2018 17:36:48 +0000 (10:36 -0700)
committerJames D. Forrester <jforrester@wikimedia.org>
Wed, 31 Oct 2018 17:36:48 +0000 (10:36 -0700)
Non-breaking change. Remaining uses are public interfaces (a constant, two
globals, a config sub-parameter, SQL queries, storage function names), one i18n
message key, and a whole lot of maintenance scripts with calls to the deprecated
function wfWaitForSlaves().

Change-Id: I6ee5ca92ccf6a80c08f53d9efe38ebb4b05064d7

includes/OutputPage.php
includes/Storage/DerivedPageDataUpdater.php
includes/Title.php
includes/api/ApiBase.php
includes/search/SearchDatabase.php
includes/user/User.php
tests/phpunit/includes/db/LBFactoryTest.php
tests/phpunit/includes/libs/objectcache/ReplicatedBagOStuffTest.php

index aa2afe9..2306788 100644 (file)
@@ -2924,7 +2924,7 @@ class OutputPage extends ContextSource {
         * then the warning is a bit more obvious. If the lag is
         * lower than $wgSlaveLagWarning, then no warning is shown.
         *
-        * @param int $lag Slave lag
+        * @param int $lag Replica lag
         */
        public function showLagWarning( $lag ) {
                $config = $this->getConfig();
index e908968..ad29f91 100644 (file)
@@ -279,7 +279,7 @@ class DerivedPageDataUpdater implements IDBAccessObject {
                $this->jobQueueGroup = $jobQueueGroup;
                $this->messageCache = $messageCache;
                $this->contLang = $contLang;
-               // XXX only needed for waiting for slaves to catch up; there should be a narrower
+               // XXX only needed for waiting for replicas to catch up; there should be a narrower
                // interface for that.
                $this->loadbalancerFactory = $loadbalancerFactory;
        }
index 51d8b13..4fa6fb1 100644 (file)
@@ -2687,9 +2687,9 @@ class Title implements LinkTarget {
                        $errors[] = [ 'confirmedittext' ];
                }
 
-               $useSlave = ( $rigor !== 'secure' );
+               $useReplica = ( $rigor !== 'secure' );
                if ( ( $action == 'edit' || $action == 'create' )
-                       && !$user->isBlockedFrom( $this, $useSlave )
+                       && !$user->isBlockedFrom( $this, $useReplica )
                ) {
                        // Don't block the user from editing their own talk page unless they've been
                        // explicitly blocked from that too.
index c66e5d5..1149d1e 100644 (file)
@@ -271,7 +271,7 @@ abstract class ApiBase extends ContextSource {
        private $mMainModule;
        /** @var string */
        private $mModuleName, $mModulePrefix;
-       private $mSlaveDB = null;
+       private $mReplicaDB = null;
        private $mParamCache = [];
        /** @var array|null|bool */
        private $mModuleSource = false;
@@ -647,11 +647,11 @@ abstract class ApiBase extends ContextSource {
         * @return IDatabase
         */
        protected function getDB() {
-               if ( !isset( $this->mSlaveDB ) ) {
-                       $this->mSlaveDB = wfGetDB( DB_REPLICA, 'api' );
+               if ( !isset( $this->mReplicaDB ) ) {
+                       $this->mReplicaDB = wfGetDB( DB_REPLICA, 'api' );
                }
 
-               return $this->mSlaveDB;
+               return $this->mReplicaDB;
        }
 
        /**
index 93f8d23..54bfd28 100644 (file)
@@ -30,7 +30,7 @@ use Wikimedia\Rdbms\IDatabase;
  */
 abstract class SearchDatabase extends SearchEngine {
        /**
-        * @var IDatabase Slave database for reading from for results
+        * @var IDatabase Replica database from which to read results
         */
        protected $db;
 
index 11cfd49..d783aaa 100644 (file)
@@ -1822,11 +1822,11 @@ class User implements IDBAccessObject, UserIdentity {
 
        /**
         * Get blocking information
-        * @param bool $bFromSlave Whether to check the replica DB first.
+        * @param bool $bFromReplica 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 ) {
+       private function getBlockedStatus( $bFromReplica = true ) {
                global $wgProxyWhitelist, $wgUser, $wgApplyIpBlocksToXff, $wgSoftBlockRanges;
 
                if ( -1 != $this->mBlockedby ) {
@@ -1858,7 +1858,7 @@ class User implements IDBAccessObject, UserIdentity {
                }
 
                // User/IP blocking
-               $block = Block::newFromTarget( $this, $ip, !$bFromSlave );
+               $block = Block::newFromTarget( $this, $ip, !$bFromReplica );
 
                // Cookie blocking
                if ( !$block instanceof Block ) {
@@ -1894,7 +1894,7 @@ class User implements IDBAccessObject, UserIdentity {
                        $xff = $this->getRequest()->getHeader( 'X-Forwarded-For' );
                        $xff = array_map( 'trim', explode( ',', $xff ) );
                        $xff = array_diff( $xff, [ $ip ] );
-                       $xffblocks = Block::getBlocksForIPList( $xff, $this->isAnon(), !$bFromSlave );
+                       $xffblocks = Block::getBlocksForIPList( $xff, $this->isAnon(), !$bFromReplica );
                        $block = Block::chooseBlock( $xffblocks, $xff );
                        if ( $block instanceof Block ) {
                                # Mangle the reason to alert the user that the block
@@ -2270,22 +2270,22 @@ class User implements IDBAccessObject, UserIdentity {
        /**
         * Check if user is blocked
         *
-        * @param bool $bFromSlave Whether to check the replica DB instead of
+        * @param bool $bFromReplica 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
         */
-       public function isBlocked( $bFromSlave = true ) {
-               return $this->getBlock( $bFromSlave ) instanceof Block && $this->getBlock()->prevents( 'edit' );
+       public function isBlocked( $bFromReplica = true ) {
+               return $this->getBlock( $bFromReplica ) instanceof Block && $this->getBlock()->prevents( 'edit' );
        }
 
        /**
         * Get the block affecting the user, or null if the user is not blocked
         *
-        * @param bool $bFromSlave Whether to check the replica DB instead of the master
+        * @param bool $bFromReplica Whether to check the replica DB instead of the master
         * @return Block|null
         */
-       public function getBlock( $bFromSlave = true ) {
-               $this->getBlockedStatus( $bFromSlave );
+       public function getBlock( $bFromReplica = true ) {
+               $this->getBlockedStatus( $bFromReplica );
                return $this->mBlock instanceof Block ? $this->mBlock : null;
        }
 
@@ -2293,14 +2293,14 @@ class User implements IDBAccessObject, UserIdentity {
         * Check if user is blocked from editing a particular article
         *
         * @param Title $title Title to check
-        * @param bool $fromSlave Whether to check the replica DB instead of the master
+        * @param bool $fromReplica Whether to check the replica DB instead of the master
         * @return bool
         */
-       public function isBlockedFrom( $title, $fromSlave = false ) {
+       public function isBlockedFrom( $title, $fromReplica = false ) {
                $blocked = $this->isHidden();
 
                if ( !$blocked ) {
-                       $block = $this->getBlock( $fromSlave );
+                       $block = $this->getBlock( $fromReplica );
                        if ( $block ) {
                                $blocked = $block->preventsEdit( $title );
                        }
index e84998c..e865e79 100644 (file)
@@ -126,7 +126,7 @@ class LBFactoryTest extends MediaWikiTestCase {
                                'load'        => 0,
                                'flags'       => DBO_TRX // REPEATABLE-READ for consistency
                        ],
-                       [ // emulated slave
+                       [ // emulated replica
                                'host'        => $wgDBserver,
                                'dbname'      => $wgDBname,
                                'user'        => $wgDBuser,
@@ -152,7 +152,7 @@ class LBFactoryTest extends MediaWikiTestCase {
                        'cluster master set' );
 
                $dbr = $lb->getConnection( DB_REPLICA );
-               $this->assertTrue( $dbr->getLBInfo( 'replica' ), 'slave shows as slave' );
+               $this->assertTrue( $dbr->getLBInfo( 'replica' ), 'replica shows as replica' );
                $this->assertEquals(
                        ( $wgDBserver != '' ) ? $wgDBserver : 'localhost',
                        $dbr->getLBInfo( 'clusterMasterHost' ),
@@ -169,7 +169,7 @@ class LBFactoryTest extends MediaWikiTestCase {
                $this->assertTrue( $dbw->getLBInfo( 'master' ), 'master shows as master' );
 
                $dbr = $factory->getMainLB()->getConnection( DB_REPLICA );
-               $this->assertTrue( $dbr->getLBInfo( 'replica' ), 'slave shows as slave' );
+               $this->assertTrue( $dbr->getLBInfo( 'replica' ), 'replica shows as replica' );
 
                // Destructor should trigger without round stage errors
                unset( $factory );
index 1b502ec..b7f22ec 100644 (file)
@@ -29,7 +29,7 @@ class ReplicatedBagOStuffTest extends MediaWikiTestCase {
 
                // Write to master.
                $this->assertEquals( $this->writeCache->get( $key ), $value );
-               // Don't write to slave. Replication is deferred to backend.
+               // Don't write to replica. Replication is deferred to backend.
                $this->assertEquals( $this->readCache->get( $key ), false );
        }
 
@@ -44,7 +44,7 @@ class ReplicatedBagOStuffTest extends MediaWikiTestCase {
                $read = wfRandomString();
                $this->readCache->set( $key, $read );
 
-               // Read from slave.
+               // Read from replica.
                $this->assertEquals( $this->cache->get( $key ), $read );
        }