Merge "Added a hasMasterConnection() method to LoadBalancer"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Sat, 19 Jul 2014 23:29:36 +0000 (23:29 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Sat, 19 Jul 2014 23:29:36 +0000 (23:29 +0000)
includes/GlobalFunctions.php
includes/db/LoadBalancer.php

index fc99b58..feca005 100644 (file)
@@ -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 );
index 5353288..01440f4 100644 (file)
@@ -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.