From 7fd8d513c4554994163d7e8cd34af6b9f0ddfa6a Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Thu, 4 Apr 2013 10:29:09 -0700 Subject: [PATCH] Fixed fatal when using fake load balancers. The error was: Catchable fatal error: Argument 1 passed to DatabaseMysql::masterPosWait() must implement interface DBMasterPos, boolean given, called in /var/www/DevWiki/core/includes/db/LoadBalancer.php on line 419 Change-Id: I230585930c1424b0868f9aa290167c66bc6848bd --- includes/GlobalFunctions.php | 6 +++++- includes/db/LoadBalancer.php | 6 +++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 1a4b985c41..bda7fec821 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -3615,7 +3615,11 @@ function wfWaitForSlaves( $maxLag = false, $wiki = false ) { if ( $lb->getServerCount() > 1 ) { $dbw = $lb->getConnection( DB_MASTER, array(), $wiki ); $pos = $dbw->getMasterPos(); - $lb->waitForAll( $pos ); + // The DBMS may not support getMasterPos() or the whole + // load balancer might be fake (e.g. $wgAllDBsAreLocalhost). + if ( $pos !== false ) { + $lb->waitForAll( $pos ); + } } } diff --git a/includes/db/LoadBalancer.php b/includes/db/LoadBalancer.php index 187870fdbe..57d48f41a9 100644 --- a/includes/db/LoadBalancer.php +++ b/includes/db/LoadBalancer.php @@ -348,7 +348,7 @@ class LoadBalancer { * Set the master wait position * If a DB_SLAVE connection has been opened already, waits * Otherwise sets a variable telling it to wait if such a connection is opened - * @param $pos int + * @param $pos DBMasterPos */ public function waitFor( $pos ) { wfProfileIn( __METHOD__ ); @@ -366,7 +366,7 @@ class LoadBalancer { /** * Set the master wait position and wait for ALL slaves to catch up to it - * @param $pos int + * @param $pos DBMasterPos */ public function waitForAll( $pos ) { wfProfileIn( __METHOD__ ); @@ -399,7 +399,7 @@ class LoadBalancer { * @param $open bool * @return bool */ - function doWait( $index, $open = false ) { + protected function doWait( $index, $open = false ) { # Find a connection to wait on $conn = $this->getAnyOpenConnection( $index ); if ( !$conn ) { -- 2.20.1