From 583fd0b623f50d44763aac68c2321876a117c8d8 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Mon, 5 Sep 2016 18:46:11 -0700 Subject: [PATCH] Make Maintenance::commitTransaction() avoid using deprecated method Change-Id: I0bbbdf492265f05ede4864aca0b4df15c3e83754 --- maintenance/Maintenance.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/maintenance/Maintenance.php b/maintenance/Maintenance.php index 0b61738a5e..818eb93e79 100644 --- a/maintenance/Maintenance.php +++ b/maintenance/Maintenance.php @@ -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. @@ -1276,11 +1276,17 @@ abstract class Maintenance { */ 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; + } } /** -- 2.20.1