return $ok;
}
+ /**
+ * @see ILoadBalancer::getConnection()
+ *
+ * @param int $i
+ * @param array $groups
+ * @param bool $domain
+ * @return Database
+ * @throws DBConnectionError
+ */
public function getConnection( $i, $groups = [], $domain = false ) {
if ( $i === null || $i === false ) {
throw new InvalidArgumentException( 'Attempt to call ' . __METHOD__ .
# Couldn't find a working server in getReaderIndex()?
if ( $i === false ) {
$this->mLastError = 'No working replica DB server: ' . $this->mLastError;
-
- return $this->reportConnectionError();
+ // Throw an exception
+ $this->reportConnectionError();
+ return null; // not reached
}
}
# Now we have an explicit index into the servers array
$conn = $this->openConnection( $i, $domain );
if ( !$conn ) {
- return $this->reportConnectionError();
+ // Throw an exception
+ $this->reportConnectionError();
+ return null; // not reached
}
# Profile any new connections that happen
return new DBConnRef( $this, [ $db, $groups, $domain ] );
}
+ /**
+ * @see ILoadBalancer::openConnection()
+ *
+ * @param int $i
+ * @param bool $domain
+ * @return bool|Database
+ * @throws DBAccessError
+ */
public function openConnection( $i, $domain = false ) {
if ( $this->localDomain->equals( $domain ) || $domain === $this->localDomainIdAlias ) {
$domain = false; // local connection requested
*
* @param int $i Server index
* @param string $domain Domain ID to open
- * @return IDatabase
+ * @return Database
*/
private function openForeignConnection( $i, $domain ) {
$domainInstance = DatabaseDomain::newFromId( $domain );
*
* @param array $server
* @param string|bool $dbNameOverride Use "" to not select any database
- * @return IDatabase
+ * @return Database
* @throws DBAccessError
* @throws InvalidArgumentException
*/
/**
* @throws DBConnectionError
- * @return bool
*/
private function reportConnectionError() {
- $conn = $this->mErrorConnection; // The connection which caused the error
+ $conn = $this->mErrorConnection; // the connection which caused the error
$context = [
'method' => __METHOD__,
'last_error' => $this->mLastError,
// throws DBConnectionError
$conn->reportConnectionError( "{$this->mLastError} ({$context['db_server']})" );
}
-
- return false; /* not reached */
}
public function getWriterIndex() {