22 use InvalidArgumentException;
38 private $loadBalancer;
61 if ( !is_string( $domain ) && $domain !==
false ) {
62 throw new InvalidArgumentException(
'$dbName must be a string, or false.' );
65 $this->loadBalancer = $loadBalancer;
66 $this->domain = $domain;
67 $this->groups = $groups;
76 private function getConnection( $i, ?array $groups =
null,
int $flags = 0 ) {
77 $groups ??= $this->groups;
78 return $this->loadBalancer->getConnection( $i, $groups, $this->domain, $flags );
86 private function getConnectionRef( $i, array $groups =
null ) {
87 $groups ??= $this->groups;
88 return $this->loadBalancer->getConnectionRef( $i, $groups, $this->domain );
100 return $this->getConnection(
DB_PRIMARY,
null, $flags );
113 $groups ??= $this->groups;
114 return $this->getConnection(
DB_REPLICA, $groups, $flags );
123 wfDeprecated(
'ConnectionManager::releaseConnection()',
'1.38' );
124 $this->loadBalancer->reuseConnection( $db );
136 wfDeprecated(
'ConnectionManager::getWriteConnectionRef()',
'1.39' );
149 wfDeprecated(
'ConnectionManager::getReadConnectionRef()',
'1.38' );
150 $groups ??= $this->groups;
151 return $this->getConnectionRef(
DB_REPLICA, $groups );
162 wfDeprecated(
'ConnectionManager::getLazyWriteConnectionRef()',
'1.39' );
175 wfDeprecated(
'ConnectionManager::getLazyReadConnectionRef()',
'1.39' );
176 $groups ??= $this->groups;
177 return $this->getConnectionRef(
DB_REPLICA, $groups );
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that a deprecated feature was used.