Skip to content

Commit 04fcc09

Browse files
Ladsgroupjenkins-bot
authored andcommitted
repo: Remove dumpDBDefaultGroup config
It can be done in a much simpler and easier way because of I973a45815d07de83 Depends-On: I973a45815d07de83c0fa0e5259b72732240911d5 Bug: T405087 Change-Id: I79ef110b0e762ddadd219c882f0e73a491995fe6
1 parent a721b71 commit 04fcc09

File tree

3 files changed

+9
-38
lines changed

3 files changed

+9
-38
lines changed

repo/config/Wikibase.default.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,9 +303,6 @@
303303
// Search profiles available in wbsearchentities & query+wbsearch
304304
'searchProfiles' => [ 'default' => null ],
305305

306-
// DB group to use in dump maintenance scripts. Defaults to "dump", per T147169.
307-
'dumpDBDefaultGroup' => 'dump',
308-
309306
'useKartographerGlobeCoordinateFormatter' => false,
310307

311308
'useKartographerMaplinkInWikitext' => false,

repo/maintenance/DumpEntities.php

Lines changed: 8 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,11 @@
33
namespace Wikibase\Repo\Maintenance;
44

55
use MediaWiki\Maintenance\Maintenance;
6-
use MediaWiki\Registration\ExtensionRegistry;
7-
use MediaWiki\Settings\SettingsBuilder;
86
use Onoi\MessageReporter\ObservableMessageReporter;
97
use Wikibase\DataModel\Services\EntityId\EntityIdPager;
108
use Wikibase\DataModel\Services\Lookup\EntityLookupException;
119
use Wikibase\Lib\Reporting\ExceptionHandler;
1210
use Wikibase\Lib\Reporting\ReportingExceptionHandler;
13-
use Wikibase\Lib\WikibaseSettings;
1411
use Wikibase\Repo\Dumpers\DumpGenerator;
1512
use Wikibase\Repo\IO\EntityIdReader;
1613
use Wikibase\Repo\IO\LineReader;
@@ -170,6 +167,14 @@ private function closeLogFile() {
170167
* Do the actual work. All child classes will need to implement this
171168
*/
172169
public function execute() {
170+
if ( $this->hasOption( 'dbgroupdefault' ) ) {
171+
// make sure Maintenance::getLBFactory() (private) applies the dbgroupdefault
172+
// option to the LBFactory in the service container.
173+
$this->getReplicaDB();
174+
} else {
175+
$this->getServiceContainer()->getDBLoadBalancerFactory()->setDefaultGroupName( 'dump' );
176+
}
177+
173178
//TODO: more validation for options
174179
$shardingFactor = (int)$this->getOption( 'sharding-factor', 1 );
175180
$shard = (int)$this->getOption( 'shard', 0 );
@@ -251,38 +256,6 @@ public function execute() {
251256
$this->closeLogFile();
252257
}
253258

254-
/**
255-
* @inheritDoc
256-
*/
257-
public function finalSetup( SettingsBuilder $settingsBuilder ) {
258-
parent::finalSetup( $settingsBuilder );
259-
260-
if ( $this->hasOption( 'dbgroupdefault' ) ) {
261-
// A group was set via cli, so no need to set the default here
262-
return;
263-
}
264-
265-
$settingsBuilder->registerHookHandlers( [ 'MediaWikiServices' => [ function() {
266-
global $wgDBDefaultGroup;
267-
if ( !ExtensionRegistry::getInstance()->isLoaded( 'WikibaseRepository' ) ) {
268-
// Something instantiates the MediaWikiServices before Wikibase
269-
// is loaded, nothing we can do here.
270-
wfWarn( self::class . ': Can not change default DB group.' );
271-
272-
return;
273-
}
274-
275-
// Don't use WikibaseRepo or MediaWikiServices here as this is run very early on, thus
276-
// the bootstrapping code is not ready yet (T202452).
277-
$settings = WikibaseSettings::getRepoSettings();
278-
$dumpDBDefaultGroup = $settings->getSetting( 'dumpDBDefaultGroup' );
279-
280-
if ( $dumpDBDefaultGroup !== null ) {
281-
$wgDBDefaultGroup = $dumpDBDefaultGroup;
282-
}
283-
} ] ] );
284-
}
285-
286259
/**
287260
* @return string[]
288261
*/

repo/tests/phpunit/unit/RepoNoBadUsageTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ protected static function getBadPatternsWithAllowedUsages(): array {
3535
'WikibaseRepo.ServiceWiring.php' => 2, // RepoDomainDbFactory+TermsDomainDbFactory service wiring
3636
'tests/phpunit/includes/Store/Sql/WikiPageEntityMetaDataLookupTest.php' => true, // mock
3737
'tests/phpunit/unit/ServiceWiringTestCase.php' => true, // mock
38+
'maintenance/DumpEntities.php' => 1, // To set the dump db group
3839
],
3940
];
4041
}

0 commit comments

Comments
 (0)