Previously, in such cases where a master connection was needed
and could not be acquired, a fatal error would occur. Instead,
throw a DBReplicationWaitError exception.
Also removed a redundant documentation block for the method.
Change-Id: Ide3015d57673df0876daf265a0182fe41004052d
}
}
- /**
- * @param IDatabase $conn
- * @param DBMasterPos|bool $pos
- * @param int|null $timeout
- * @return bool
- */
public function safeWaitForMasterPos( IDatabase $conn, $pos = false, $timeout = null ) {
$timeout = max( 1, $timeout ?: $this->waitTimeout );
$pos = $masterConn->getMasterPos();
} else {
$masterConn = $this->openConnection( $this->getWriterIndex(), self::DOMAIN_ANY );
+ if ( !$masterConn ) {
+ throw new DBReplicationWaitError(
+ null,
+ "Could not obtain a master database connection to get the position"
+ );
+ }
$pos = $masterConn->getMasterPos();
$this->closeConnection( $masterConn );
}