Skip to content

Commit 92bed22

Browse files
committed
1.1.3 (Use separate DB connection when creating an incremental ID)
1 parent a823432 commit 92bed22

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

IDProvider.functions.php

+10-11
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* @file
99
* @ingroup Extensions
1010
*/
11-
11+
1212
class IDProviderFunctions {
1313

1414

@@ -95,11 +95,10 @@ private static function calculateIncrement($prefix) {
9595
// Get DB with read access
9696
// > MW 1.27
9797
if ( class_exists( '\MediaWiki\MediaWikiServices' ) && method_exists( '\MediaWiki\MediaWikiServices', 'getDBLoadBalancerFactory' ) ) {
98-
$factory = \MediaWiki\MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
99-
$mainLB = $factory->getMainLB();
100-
$dbw = $mainLB->getConnectionRef( DB_MASTER );
101-
$factory->beginMasterChanges(__METHOD__);
102-
} else {
98+
$lb = \MediaWiki\MediaWikiServices::getInstance()->getDBLoadBalancerFactory()->newMainLB();
99+
$dbw = $lb->getConnection( DB_MASTER );
100+
$dbw->clearFlag( DBO_TRX );
101+
} else {
103102
$dbw = wfGetDB(DB_MASTER);
104103
$dbw->begin();
105104
}
@@ -125,7 +124,7 @@ private static function calculateIncrement($prefix) {
125124
);
126125
// > MW 1.27
127126
if ( class_exists( '\MediaWiki\MediaWikiServices' ) && method_exists( '\MediaWiki\MediaWikiServices', 'getDBLoadBalancerFactory' ) ) {
128-
$factory->commitMasterChanges(__METHOD__);
127+
$lb->disable();
129128
} else {
130129
$dbw->commit();
131130
}
@@ -149,12 +148,12 @@ private static function calculateIncrement($prefix) {
149148
);
150149
// > MW 1.27
151150
if ( class_exists( '\MediaWiki\MediaWikiServices' ) && method_exists( '\MediaWiki\MediaWikiServices', 'getDBLoadBalancerFactory' ) ) {
152-
$factory->commitMasterChanges(__METHOD__);
151+
$lb->disable();
153152
} else {
154153
$dbw->commit();
155154
}
156-
}
157-
155+
}
156+
158157
if (!$increment) {
159158
throw new Exception('Could not calculate the increment!');
160159
}
@@ -415,4 +414,4 @@ public static function toJSON($obj) {
415414
die();
416415
}
417416

418-
}
417+
}

extension.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "IDProvider",
3-
"version": "1.1.2",
3+
"version": "1.1.3",
44
"author": [
55
"Simon Heimler",
66
"Alexander Gesinn (gesinn.it GmbH & Co. KG)"
@@ -9,12 +9,12 @@
99
"descriptionmsg": "idprovider-desc",
1010
"license-name": "MIT",
1111
"type": "other",
12-
12+
1313
"APIModules": {
1414
"idprovider-increment": "IDProviderIncrementApi",
1515
"idprovider-random": "IDProviderRandomApi"
1616
},
17-
17+
1818
"AutoloadClasses": {
1919
"IDProviderHooks": "IDProvider.hooks.php",
2020
"IDProviderFunctions": "IDProvider.functions.php",
@@ -47,6 +47,6 @@
4747
"IDProviderMaxRandNumber ": 9999999999,
4848
"IDProviderRandStringLength ": 12
4949
},
50-
50+
5151
"manifest_version": 1
52-
}
52+
}

0 commit comments

Comments
 (0)