Change linter maintenance scripts to use existing config varaibles

* Having separate config variables to enable the maintenance
   migrateNamespace and migrateTagTemplate scripts is duplicitous
   and should be shared with the write enable config variables.

Bug: T329342
Change-Id: I4cb453fc0678b065cb42a2ca59863da1ab9cdbe4
(cherry picked from commit d12bf639f6)
This commit is contained in:
sbailey 2023-02-14 08:27:25 -08:00 committed by Ladsgroup
parent e2ce10d548
commit 93bdcd6218
5 changed files with 8 additions and 18 deletions

View file

@ -200,14 +200,8 @@
"LinterWriteNamespaceColumnStage": {
"value": false
},
"LinterMigrateNamespaceStage": {
"value": false
},
"LinterWriteTagAndTemplateColumnsStage": {
"value": false
},
"LinterMigrateTagAndTemplateColumnsStage": {
"value": false
}
},
"manifest_version": 2

View file

@ -442,7 +442,7 @@ class Database {
if ( !$bypassConfig ) {
$mwServices = MediaWikiServices::getInstance();
$config = $mwServices->getMainConfig();
$enableMigrateNamespaceStage = $config->get( 'LinterMigrateNamespaceStage' );
$enableMigrateNamespaceStage = $config->get( 'LinterWriteNamespaceColumnStage' );
if ( !$enableMigrateNamespaceStage ) {
return 0;
}
@ -551,7 +551,7 @@ class Database {
if ( !$bypassConfig ) {
$mwServices = MediaWikiServices::getInstance();
$config = $mwServices->getMainConfig();
$enableMigrateTagAndTemplateColumnsStage = $config->get( 'LinterMigrateTagAndTemplateColumnsStage' );
$enableMigrateTagAndTemplateColumnsStage = $config->get( 'LinterWriteTagAndTemplateColumnsStage' );
if ( !$enableMigrateTagAndTemplateColumnsStage ) {
return 0;
}

View file

@ -42,9 +42,9 @@ class MigrateNamespace extends LoggedUpdateMaintenance {
*/
protected function doDBUpdates() {
$config = $this->getConfig();
$enableMigrateNamespaceStage = $config->get( 'LinterMigrateNamespaceStage' );
$enableMigrateNamespaceStage = $config->get( 'LinterWriteNamespaceColumnStage' );
if ( !$enableMigrateNamespaceStage ) {
$this->output( "LinterMigrateNamespaceStage config value is false, code is disabled, exiting\n" );
$this->output( "LinterWriteNamespaceColumnStage config value is false, code is disabled, exiting\n" );
return false;
}

View file

@ -40,9 +40,9 @@ class MigrateTagTemplate extends LoggedUpdateMaintenance {
*/
protected function doDBUpdates() {
$config = $this->getConfig();
$enableMigrateTagAndTemplateStage = $config->get( 'LinterMigrateTagAndTemplateColumnsStage' );
$enableMigrateTagAndTemplateStage = $config->get( 'LinterWriteTagAndTemplateColumnsStage' );
if ( !$enableMigrateTagAndTemplateStage ) {
$this->output( "LinterMigrateTagAndTemplateColumnsStage config value is false, code disabled\n" );
$this->output( "LinterWriteTagAndTemplateColumnsStage config value is false, code disabled\n" );
return false;
}

View file

@ -214,8 +214,6 @@ class RecordLintJobTest extends MediaWikiIntegrationTestCase {
}
public function testMigrateNamespace() {
$this->overrideConfigValue( 'LinterMigrateNamespaceStage', true );
// Create groups of records that do not need migrating to ensure batching works properly
$namespaceIds = [ '0', '1', '2', '3', '4', '5', '4', '3', '2', '1', '0', '1', '2' ];
$writeEnables = [ false, true, true, true, false, false, true, true, false, false, false, true, false ];
@ -228,7 +226,7 @@ class RecordLintJobTest extends MediaWikiIntegrationTestCase {
$this->assertNull( $namespace );
// migrate unpopulated namespace_id(s) from the page table to linter table
Database::migrateNamespace( 2, 3, 0, false );
Database::migrateNamespace( 2, 3, 0, true );
// Verify all linter records now have proper namespace IDs in the linter_namespace field
$this->checkPagesNamespace( $titleAndPages, $namespaceIds );
@ -279,8 +277,6 @@ class RecordLintJobTest extends MediaWikiIntegrationTestCase {
}
public function testMigrateTagAndTemplate() {
$this->overrideConfigValue( 'LinterMigrateTagAndTemplateColumnsStage', true );
$error = [
'type' => 'obsolete-tag',
'location' => [ 0, 10 ],
@ -324,7 +320,7 @@ class RecordLintJobTest extends MediaWikiIntegrationTestCase {
$this->assertSame( "", $template );
// Migrate unpopulated tag and template info from the params field
Database::migrateTemplateAndTagInfo( 3, 0, false );
Database::migrateTemplateAndTagInfo( 3, 0, true );
// Verify all linter records have the proper tag and template field info migrated from the params field
$this->checkPagesTagAndTemplate( $titleAndPages );