Renamed load balancer replica DB functions for consistency
authorAaron Schulz <aschulz@wikimedia.org>
Mon, 5 Sep 2016 19:42:17 +0000 (12:42 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Mon, 5 Sep 2016 19:42:17 +0000 (12:42 -0700)
Change-Id: Iec51366d383822d2afbd3fae285e251b78b0cdc7

includes/MediaWiki.php
includes/db/loadbalancer/LBFactory.php
includes/db/loadbalancer/LoadBalancer.php
includes/skins/Skin.php

index 1add24a..35aa610 100644 (file)
@@ -582,7 +582,7 @@ class MediaWiki {
 
                // Avoid letting a few seconds of slave lag cause a month of stale data. This logic is
                // also intimately related to the value of $wgCdnReboundPurgeDelay.
-               if ( $factory->laggedSlaveUsed() ) {
+               if ( $factory->laggedReplicaUsed() ) {
                        $maxAge = $config->get( 'CdnMaxageLagged' );
                        $context->getOutput()->lowerCdnMaxage( $maxAge );
                        $request->response()->header( "X-Database-Lagged: true" );
index 9f8f919..226ac08 100644 (file)
@@ -357,18 +357,27 @@ abstract class LBFactory implements DestructibleService {
 
        /**
         * Detemine if any lagged replica DB connection was used
-        * @since 1.27
         * @return bool
+        * @since 1.28
         */
-       public function laggedSlaveUsed() {
+       public function laggedReplicaUsed() {
                $ret = false;
                $this->forEachLB( function ( LoadBalancer $lb ) use ( &$ret ) {
-                       $ret = $ret || $lb->laggedSlaveUsed();
+                       $ret = $ret || $lb->laggedReplicaUsed();
                } );
 
                return $ret;
        }
 
+       /**
+        * @return bool
+        * @since 1.27
+        * @deprecated Since 1.28; use laggedReplicaUsed()
+        */
+       public function laggedSlaveUsed() {
+               return $this->laggedReplicaUsed();
+       }
+
        /**
         * Determine if any master connection has pending/written changes from this request
         * @return bool
index d3a2902..7cdd490 100644 (file)
@@ -1421,11 +1421,10 @@ class LoadBalancer {
 
        /**
         * @note This method will trigger a DB connection if not yet done
-        *
         * @param string|bool $wiki Wiki ID, or false for the current wiki
         * @return bool Whether the generic connection for reads is highly "lagged"
         */
-       public function getLaggedSlaveMode( $wiki = false ) {
+       public function getLaggedReplicaMode( $wiki = false ) {
                // No-op if there is only one DB (also avoids recursion)
                if ( !$this->laggedReplicaMode && $this->getServerCount() > 1 ) {
                        try {
@@ -1442,13 +1441,31 @@ class LoadBalancer {
                return $this->laggedReplicaMode;
        }
 
+       /**
+        * @param bool $wiki
+        * @return bool
+        * @deprecated 1.28; use getLaggedReplicaMode()
+        */
+       public function getLaggedSlaveMode( $wiki = false ) {
+               return $this->getLaggedReplicaMode( $wiki );
+       }
+
        /**
         * @note This method will never cause a new DB connection
         * @return bool Whether any generic connection used for reads was highly "lagged"
+        * @since 1.28
+        */
+       public function laggedReplicaUsed() {
+               return $this->laggedReplicaMode;
+       }
+
+       /**
+        * @return bool
         * @since 1.27
+        * @deprecated Since 1.28; use laggedReplicaUsed()
         */
        public function laggedSlaveUsed() {
-               return $this->laggedReplicaMode;
+               return $this->laggedReplicaUsed();
        }
 
        /**
@@ -1461,7 +1478,7 @@ class LoadBalancer {
        public function getReadOnlyReason( $wiki = false, DatabaseBase $conn = null ) {
                if ( $this->readOnlyReason !== false ) {
                        return $this->readOnlyReason;
-               } elseif ( $this->getLaggedSlaveMode( $wiki ) ) {
+               } elseif ( $this->getLaggedReplicaMode( $wiki ) ) {
                        if ( $this->allReplicasDownMode ) {
                                return 'The database has been automatically locked ' .
                                        'until the replica database servers become available';
index d473251..6b4acfa 100644 (file)
@@ -846,7 +846,7 @@ abstract class Skin extends ContextSource {
                        $s = '';
                }
 
-               if ( wfGetLB()->getLaggedSlaveMode() ) {
+               if ( wfGetLB()->getLaggedReplicaMode() ) {
                        $s .= ' <strong>' . $this->msg( 'laggedslavemode' )->parse() . '</strong>';
                }