Set migration stage for change tag to read new
authorAmir Sarabadani <Ladsgroup@gmail.com>
Wed, 17 Oct 2018 12:37:11 +0000 (14:37 +0200)
committerAmir Sarabadani <Ladsgroup@gmail.com>
Fri, 2 Nov 2018 12:52:55 +0000 (13:52 +0100)
Plus removing not needed config

Bug: T185355
Change-Id: Iaa8bfbbbf4fa939bbc7a1a0ec0b00c8af97abfaa

includes/DefaultSettings.php
includes/changetags/ChangeTags.php
tests/phpunit/includes/changetags/ChangeTagsTest.php

index 15d2627..6965a15 100644 (file)
@@ -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:
index d9ca8d7..e7d08fd 100644 (file)
@@ -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();
                }
 
index f207564..cb9dd41 100644 (file)
@@ -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' ],
                                ]