From: Aaron Schulz Date: Sat, 19 Jul 2014 23:19:43 +0000 (-0700) Subject: Added a hasMasterConnection() method to LoadBalancer X-Git-Tag: 1.31.0-rc.0~14868^2 X-Git-Url: http://git.cyclocoop.org/data/Fool?a=commitdiff_plain;h=92e0d0f92718ee24d5f376b22b07162c0be2bc65;p=lhc%2Fweb%2Fwiklou.git Added a hasMasterConnection() method to LoadBalancer * Made wfWaitForSlaves() use it instead of using isOpen() incorrectly. The index for the master is 0, not DB_MASTER. This fixes 2979f0b6. Change-Id: I48e5c7f10d8fe6b8bf6e830282352e3238b5d3ae --- diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index fc99b5867f..feca005788 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -3815,7 +3815,7 @@ function wfWaitForSlaves( $ifWritesSince = false, $wiki = false, $cluster = fals // bug 27975 - Don't try to wait for slaves if there are none // Prevents permission error when getting master position if ( $lb->getServerCount() > 1 ) { - if ( $ifWritesSince && !$lb->isOpen( DB_MASTER ) ) { + if ( $ifWritesSince && !$lb->hasMasterConnection() ) { return; // assume no writes done } $dbw = $lb->getConnection( DB_MASTER, array(), $wiki ); diff --git a/includes/db/LoadBalancer.php b/includes/db/LoadBalancer.php index 53532880d1..01440f46d1 100644 --- a/includes/db/LoadBalancer.php +++ b/includes/db/LoadBalancer.php @@ -948,6 +948,14 @@ class LoadBalancer { } } + /** + * @return bool Whether a master connection is already open + * @since 1.24 + */ + function hasMasterConnection() { + return $this->isOpen( $this->getWriterIndex() ); + } + /** * Determine if there are any pending changes that need to be rolled back * or committed.