This method handles reuseConnection() calls, disallows writes to
DB_REPLICA role handles, is more consistent with wfGetDB(), and
is more efficient with I540b08920997c5.
Change-Id: I8edaef0ea4718414e2004fad04afca8ec5797669
* @return IDatabase
*/
private function getDBConnection( $index, $flags = 0 ) {
- return $this->loadBalancer->getConnection( $index, [], $this->domain, $flags );
+ return $this->loadBalancer->getConnectionRef( $index, [], $this->domain, $flags );
}
/**
use WANObjectCache;
use Wikimedia\Rdbms\IDatabase;
use Wikimedia\Rdbms\LoadBalancer;
+use Wikimedia\Rdbms\MaintainableDBConnRef;
use Wikimedia\TestingAccessWrapper;
/**
->disableOriginalConstructor()
->getMock();
$mock->expects( $this->any() )
- ->method( 'getConnection' )
- ->willReturn( $db );
+ ->method( 'getConnectionRef' )
+ ->willReturnCallback( function ( $i ) use ( $mock, $db ) {
+ return new MaintainableDBConnRef( $mock, $db, $i );
+ } );
return $mock;
}