From 2fdf48c59c79acd3f3a6fa726dc622159a3856ef Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Mon, 5 Sep 2016 12:42:17 -0700 Subject: [PATCH] Renamed load balancer replica DB functions for consistency Change-Id: Iec51366d383822d2afbd3fae285e251b78b0cdc7 --- includes/MediaWiki.php | 2 +- includes/db/loadbalancer/LBFactory.php | 15 +++++++++++--- includes/db/loadbalancer/LoadBalancer.php | 25 +++++++++++++++++++---- includes/skins/Skin.php | 2 +- 4 files changed, 35 insertions(+), 9 deletions(-) diff --git a/includes/MediaWiki.php b/includes/MediaWiki.php index 1add24a600..35aa610732 100644 --- a/includes/MediaWiki.php +++ b/includes/MediaWiki.php @@ -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" ); diff --git a/includes/db/loadbalancer/LBFactory.php b/includes/db/loadbalancer/LBFactory.php index 9f8f919dd4..226ac0813f 100644 --- a/includes/db/loadbalancer/LBFactory.php +++ b/includes/db/loadbalancer/LBFactory.php @@ -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 diff --git a/includes/db/loadbalancer/LoadBalancer.php b/includes/db/loadbalancer/LoadBalancer.php index d3a2902a00..7cdd490b75 100644 --- a/includes/db/loadbalancer/LoadBalancer.php +++ b/includes/db/loadbalancer/LoadBalancer.php @@ -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'; diff --git a/includes/skins/Skin.php b/includes/skins/Skin.php index d4732518b2..6b4acfa2d3 100644 --- a/includes/skins/Skin.php +++ b/includes/skins/Skin.php @@ -846,7 +846,7 @@ abstract class Skin extends ContextSource { $s = ''; } - if ( wfGetLB()->getLaggedSlaveMode() ) { + if ( wfGetLB()->getLaggedReplicaMode() ) { $s .= ' ' . $this->msg( 'laggedslavemode' )->parse() . ''; } -- 2.20.1