From bb07b4a368f59fabfdcd7d08610c9f1cb6c00ba7 Mon Sep 17 00:00:00 2001 From: Amir Sarabadani Date: Wed, 17 Oct 2018 14:37:11 +0200 Subject: [PATCH] Set migration stage for change tag to read new Plus removing not needed config Bug: T185355 Change-Id: Iaa8bfbbbf4fa939bbc7a1a0ec0b00c8af97abfaa --- includes/DefaultSettings.php | 14 +--------- includes/changetags/ChangeTags.php | 6 ++--- .../includes/changetags/ChangeTagsTest.php | 26 +++++++++++-------- 3 files changed, 18 insertions(+), 28 deletions(-) diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 15d2627214..6965a15cfe 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -9013,19 +9013,7 @@ $wgActorTableSchemaMigrationStage = SCHEMA_COMPAT_OLD; * @since 1.32 * @var int One of the MIGRATION_* constants */ -$wgChangeTagsSchemaMigrationStage = MIGRATION_WRITE_BOTH; - -/** - * Temporarily flag to use change_tag_def table as backend of change tag statistics. - * For example in case of Special:Tags. If set to false, it will use change_tag table. - * Before setting it to true set $wgChangeTagsSchemaMigrationStage to MIGRATION_WRITE_BOTH and run - * PopulateChangeTagDef maintaince script. - * It's redundant when $wgChangeTagsSchemaMigrationStage is set to MIGRATION_NEW - * - * @since 1.32 - * @var bool - */ -$wgTagStatisticsNewTable = false; +$wgChangeTagsSchemaMigrationStage = MIGRATION_NEW; /** * For really cool vim folding this needs to be at the end: diff --git a/includes/changetags/ChangeTags.php b/includes/changetags/ChangeTags.php index d9ca8d7b9a..e7d08fdb6f 100644 --- a/includes/changetags/ChangeTags.php +++ b/includes/changetags/ChangeTags.php @@ -1585,10 +1585,8 @@ class ChangeTags { * @return array Array of string => int */ public static function tagUsageStatistics() { - global $wgChangeTagsSchemaMigrationStage, $wgTagStatisticsNewTable; - if ( $wgChangeTagsSchemaMigrationStage > MIGRATION_WRITE_BOTH || - ( $wgTagStatisticsNewTable && $wgChangeTagsSchemaMigrationStage > MIGRATION_OLD ) - ) { + global $wgChangeTagsSchemaMigrationStage; + if ( $wgChangeTagsSchemaMigrationStage > MIGRATION_WRITE_BOTH ) { return self::newTagUsageStatistics(); } diff --git a/tests/phpunit/includes/changetags/ChangeTagsTest.php b/tests/phpunit/includes/changetags/ChangeTagsTest.php index f20756425f..cb9dd4145c 100644 --- a/tests/phpunit/includes/changetags/ChangeTagsTest.php +++ b/tests/phpunit/includes/changetags/ChangeTagsTest.php @@ -30,6 +30,8 @@ class ChangeTagsTest extends MediaWikiTestCase { /** @dataProvider provideModifyDisplayQuery */ public function testModifyDisplayQuery( $origQuery, $filter_tag, $useTags, $modifiedQuery ) { $this->setMwGlobals( 'wgUseTagFilter', $useTags ); + $rcId = 123; + ChangeTags::updateTags( [ 'foo', 'bar' ], [], $rcId ); // HACK resolve deferred group concats (see comment in provideModifyDisplayQuery) if ( isset( $modifiedQuery['fields']['ts_tags'] ) ) { $modifiedQuery['fields']['ts_tags'] = call_user_func_array( @@ -61,11 +63,13 @@ class ChangeTagsTest extends MediaWikiTestCase { public function provideModifyDisplayQuery() { // HACK if we call $dbr->buildGroupConcatField() now, it will return the wrong table names // We have to have the test runner call it instead + $baseConcats = [ ',', [ 'change_tag', 'change_tag_def' ], 'ctd_name' ]; + $joinConds = [ 'change_tag_def' => [ 'INNER JOIN', 'ct_tag_id=ctd_id' ] ]; $groupConcats = [ - 'recentchanges' => [ ',', 'change_tag', 'ct_tag', 'ct_rc_id=rc_id' ], - 'logging' => [ ',', 'change_tag', 'ct_tag', 'ct_log_id=log_id' ], - 'revision' => [ ',', 'change_tag', 'ct_tag', 'ct_rev_id=rev_id' ], - 'archive' => [ ',', 'change_tag', 'ct_tag', 'ct_rev_id=ar_rev_id' ], + 'recentchanges' => array_merge( $baseConcats, [ 'ct_rc_id=rc_id', $joinConds ] ), + 'logging' => array_merge( $baseConcats, [ 'ct_log_id=log_id', $joinConds ] ), + 'revision' => array_merge( $baseConcats, [ 'ct_rev_id=rev_id', $joinConds ] ), + 'archive' => array_merge( $baseConcats, [ 'ct_rev_id=ar_rev_id', $joinConds ] ), ]; return [ @@ -118,7 +122,7 @@ class ChangeTagsTest extends MediaWikiTestCase { [ 'tables' => [ 'recentchanges', 'change_tag' ], 'fields' => [ 'rc_id', 'rc_timestamp', 'ts_tags' => $groupConcats['recentchanges'] ], - 'conds' => [ "rc_timestamp > '20170714183203'", 'ct_tag' => 'foo' ], + 'conds' => [ "rc_timestamp > '20170714183203'", 'ct_tag_id' => [ 1 ] ], 'join_conds' => [ 'change_tag' => [ 'INNER JOIN', 'ct_rc_id=rc_id' ] ], 'options' => [ 'ORDER BY' => 'rc_timestamp DESC' ], ] @@ -136,7 +140,7 @@ class ChangeTagsTest extends MediaWikiTestCase { [ 'tables' => [ 'logging', 'change_tag' ], 'fields' => [ 'log_id', 'ts_tags' => $groupConcats['logging'] ], - 'conds' => [ "log_timestamp > '20170714183203'", 'ct_tag' => 'foo' ], + 'conds' => [ "log_timestamp > '20170714183203'", 'ct_tag_id' => [ 1 ] ], 'join_conds' => [ 'change_tag' => [ 'INNER JOIN', 'ct_log_id=log_id' ] ], 'options' => [ 'ORDER BY log_timestamp DESC' ], ] @@ -154,7 +158,7 @@ class ChangeTagsTest extends MediaWikiTestCase { [ 'tables' => [ 'revision', 'change_tag' ], 'fields' => [ 'rev_id', 'rev_timestamp', 'ts_tags' => $groupConcats['revision'] ], - 'conds' => [ "rev_timestamp > '20170714183203'", 'ct_tag' => 'foo' ], + 'conds' => [ "rev_timestamp > '20170714183203'", 'ct_tag_id' => [ 1 ] ], 'join_conds' => [ 'change_tag' => [ 'INNER JOIN', 'ct_rev_id=rev_id' ] ], 'options' => [ 'ORDER BY' => 'rev_timestamp DESC' ], ] @@ -172,7 +176,7 @@ class ChangeTagsTest extends MediaWikiTestCase { [ 'tables' => [ 'archive', 'change_tag' ], 'fields' => [ 'ar_id', 'ar_timestamp', 'ts_tags' => $groupConcats['archive'] ], - 'conds' => [ "ar_timestamp > '20170714183203'", 'ct_tag' => 'foo' ], + 'conds' => [ "ar_timestamp > '20170714183203'", 'ct_tag_id' => [ 1 ] ], 'join_conds' => [ 'change_tag' => [ 'INNER JOIN', 'ct_rev_id=ar_rev_id' ] ], 'options' => [ 'ORDER BY' => 'ar_timestamp DESC' ], ] @@ -220,7 +224,7 @@ class ChangeTagsTest extends MediaWikiTestCase { [ 'tables' => [ 'recentchanges', 'change_tag' ], 'fields' => [ 'rc_id', 'rc_timestamp', 'ts_tags' => $groupConcats['recentchanges'] ], - 'conds' => [ "rc_timestamp > '20170714183203'", 'ct_tag' => [ 'foo', 'bar' ] ], + 'conds' => [ "rc_timestamp > '20170714183203'", 'ct_tag_id' => [ 1, 2 ] ], 'join_conds' => [ 'change_tag' => [ 'INNER JOIN', 'ct_rc_id=rc_id' ] ], 'options' => [ 'ORDER BY' => 'rc_timestamp DESC', 'DISTINCT' ], ] @@ -238,7 +242,7 @@ class ChangeTagsTest extends MediaWikiTestCase { [ 'tables' => [ 'recentchanges', 'change_tag' ], 'fields' => [ 'rc_id', 'rc_timestamp', 'ts_tags' => $groupConcats['recentchanges'] ], - 'conds' => [ "rc_timestamp > '20170714183203'", 'ct_tag' => [ 'foo', 'bar' ] ], + 'conds' => [ "rc_timestamp > '20170714183203'", 'ct_tag_id' => [ 1, 2 ] ], 'join_conds' => [ 'change_tag' => [ 'INNER JOIN', 'ct_rc_id=rc_id' ] ], 'options' => [ 'DISTINCT', 'ORDER BY' => 'rc_timestamp DESC' ], ] @@ -256,7 +260,7 @@ class ChangeTagsTest extends MediaWikiTestCase { [ 'tables' => [ 'recentchanges', 'change_tag' ], 'fields' => [ 'rc_id', 'ts_tags' => $groupConcats['recentchanges'] ], - 'conds' => [ "rc_timestamp > '20170714183203'", 'ct_tag' => [ 'foo', 'bar' ] ], + 'conds' => [ "rc_timestamp > '20170714183203'", 'ct_tag_id' => [ 1, 2 ] ], 'join_conds' => [ 'change_tag' => [ 'INNER JOIN', 'ct_rc_id=rc_id' ] ], 'options' => [ 'ORDER BY rc_timestamp DESC', 'DISTINCT' ], ] -- 2.20.1