$this->defaultGroup = $params['defaultGroup'] ?? null;
}
- /**
- * Get the local (and default) database domain ID of connection handles
- *
- * @see DatabaseDomain
- * @return string Database domain ID; this specifies DB name, schema, and table prefix
- * @since 1.31
- */
public function getLocalDomainID() {
return $this->localDomain->getId();
}
+ public function resolveDomainID( $domain ) {
+ return ( $domain !== false ) ? (string)$domain : $this->getLocalDomainID();
+ }
+
/**
* Get a LoadMonitor instance
*
* Wait for a given replica DB to catch up to the master pos stored in $this
* @param int $index Server index
* @param bool $open Check the server even if a new connection has to be made
- * @param int $timeout Max seconds to wait; default is "waitTimeout" given to __construct()
+ * @param int|null $timeout Max seconds to wait; default is "waitTimeout" given to __construct()
* @return bool
*/
protected function doWait( $index, $open = false, $timeout = null ) {
}
public function getConnectionRef( $db, $groups = [], $domain = false, $flags = 0 ) {
- $domain = ( $domain !== false ) ? $domain : $this->localDomain;
+ $domain = $this->resolveDomainID( $domain );
return new DBConnRef( $this, $this->getConnection( $db, $groups, $domain, $flags ) );
}
public function getLazyConnectionRef( $db, $groups = [], $domain = false, $flags = 0 ) {
- $domain = ( $domain !== false ) ? $domain : $this->localDomain;
+ $domain = $this->resolveDomainID( $domain );
return new DBConnRef( $this, [ $db, $groups, $domain, $flags ] );
}
public function getMaintenanceConnectionRef( $db, $groups = [], $domain = false, $flags = 0 ) {
- $domain = ( $domain !== false ) ? $domain : $this->localDomain;
+ $domain = $this->resolveDomainID( $domain );
return new MaintainableDBConnRef(
$this, $this->getConnection( $db, $groups, $domain, $flags ) );