objectcache: Minor clean up SqlBagOStuff::getConnectionFromServerInfo

Follows-up I8ba1d35f0e36ae259 which started a mix between hanging $server
for one key, and merging with an inline array for their keys. Move the
remaining two changes out for consistency, so that there is not a state
where $server is left in a "wrong" state where it is only partially correct.

Clarify reason for deducting DBO_TRX.

Change-Id: I1bf57dea5f1a755152e84d4984144369fc392e2f
This commit is contained in:
Timo Tijhof 2023-09-05 19:08:28 +01:00 committed by D3r1ck01
parent 741d962196
commit 00dc6de657

View file

@ -1676,25 +1676,20 @@ class SqlBagOStuff extends MediumSpecificBagOStuff {
private function getConnectionFromServerInfo( $shardIndex, array $server ) {
if ( !isset( $this->conns[$shardIndex] ) ) {
$services = MediaWikiServices::getInstance();
$dbFactory = $services->getDatabaseFactory();
$sqlDump = $services->getMainConfig()->get( MainConfigNames::DebugDumpSql );
$debugSql = $services->getMainConfig()->get( MainConfigNames::DebugDumpSql );
$server['flags'] ??= 0;
if ( $sqlDump ) {
if ( $debugSql ) {
$server['flags'] |= DBO_DEBUG;
}
// Make sure this handle always uses autocommit mode, even if DBO_TRX is
// configured.
$server['flags'] &= ~DBO_TRX;
$server['logger'] = $this->logger;
/** @var IMaintainableDatabase $conn Auto-commit connection to the server */
$conn = $dbFactory->create(
$server['type'],
array_merge(
$server,
[
// Make sure the handle uses autocommit mode
'flags' => ( $server['flags'] ) & ~IDatabase::DBO_TRX,
'logger' => $this->logger,
]
)
);
$conn = $services->getDatabaseFactory()->create( $server['type'], $server );
// Automatically create the objectcache table for sqlite as needed
if ( $conn->getType() === 'sqlite' ) {
$this->initSqliteDatabase( $conn );