Merge "Make Maintenance::commitTransaction() avoid using deprecated method"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 6 Sep 2016 06:16:42 +0000 (06:16 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 6 Sep 2016 06:16:42 +0000 (06:16 +0000)
1  2 
maintenance/Maintenance.php

@@@ -109,7 -109,7 +109,7 @@@ abstract class Maintenance 
        private $mDb = null;
  
        /** @var float UNIX timestamp */
-       private $lastSlaveWait = 0.0;
+       private $lastReplicationWait = 0.0;
  
        /**
         * Used when creating separate schema files.
         * If not set, wfGetDB() will be used.
         * This function has the same parameters as wfGetDB()
         *
 -       * @param integer $db DB index (DB_SLAVE/DB_MASTER)
 +       * @param integer $db DB index (DB_REPLICA/DB_MASTER)
         * @param array $groups; default: empty array
         * @param string|bool $wiki; default: current wiki
         * @return IDatabase
         */
        protected function commitTransaction( IDatabase $dbw, $fname ) {
                $dbw->commit( $fname );
+               try {
+                       $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
+                       $lbFactory->waitForReplication(
+                               [ 'timeout' => 30, 'ifWritesSince' => $this->lastReplicationWait ]
+                       );
+                       $this->lastReplicationWait = microtime( true );
  
-               $ok = wfWaitForSlaves( $this->lastSlaveWait, false, '*', 30 );
-               $this->lastSlaveWait = microtime( true );
-               return $ok;
+                       return true;
+               } catch ( DBReplicationWaitError $e ) {
+                       return false;
+               }
        }
  
        /**