Merge "Add some output messages to populatePPSortKey"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 26 Jul 2017 01:30:05 +0000 (01:30 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 26 Jul 2017 01:30:05 +0000 (01:30 +0000)
includes/changetags/ChangeTags.php
includes/specials/SpecialRecentchanges.php
includes/specials/SpecialRecentchangeslinked.php
resources/src/mediawiki.rcfilters/dm/mw.rcfilters.dm.FiltersViewModel.js
resources/src/mediawiki.rcfilters/mw.rcfilters.Controller.js
resources/src/mediawiki.rcfilters/mw.rcfilters.init.js
resources/src/mediawiki.rcfilters/styles/mw.rcfilters.less
resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.ChangesListWrapperWidget.js
resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.FormWrapperWidget.js
tests/parser/ParserTestRunner.php
tests/phpunit/includes/changetags/ChangeTagsTest.php [new file with mode: 0644]

index c9b5f96..2eb9b22 100644 (file)
@@ -643,24 +643,32 @@ class ChangeTags {
         * Handles selecting tags, and filtering.
         * Needs $tables to be set up properly, so we can figure out which join conditions to use.
         *
+        * WARNING: If $filter_tag contains more than one tag, this function will add DISTINCT,
+        * which may cause performance problems for your query unless you put the ID field of your
+        * table at the end of the ORDER BY, and set a GROUP BY equal to the ORDER BY. For example,
+        * if you had ORDER BY foo_timestamp DESC, you will now need GROUP BY foo_timestamp, foo_id
+        * ORDER BY foo_timestamp DESC, foo_id DESC.
+        *
         * @param string|array $tables Table names, see Database::select
         * @param string|array $fields Fields used in query, see Database::select
         * @param string|array $conds Conditions used in query, see Database::select
         * @param array $join_conds Join conditions, see Database::select
-        * @param array $options Options, see Database::select
-        * @param bool|string $filter_tag Tag to select on
+        * @param string|array $options Options, see Database::select
+        * @param string|array $filter_tag Tag(s) to select on
         *
         * @throws MWException When unable to determine appropriate JOIN condition for tagging
         */
        public static function modifyDisplayQuery( &$tables, &$fields, &$conds,
-                                                                               &$join_conds, &$options, $filter_tag = false ) {
-               global $wgRequest, $wgUseTagFilter;
+                                                                               &$join_conds, &$options, $filter_tag = '' ) {
+               global $wgUseTagFilter;
 
-               if ( $filter_tag === false ) {
-                       $filter_tag = $wgRequest->getVal( 'tagfilter' );
-               }
+               // Normalize to arrays
+               $tables = (array)$tables;
+               $fields = (array)$fields;
+               $conds = (array)$conds;
+               $options = (array)$options;
 
-               // Figure out which conditions can be done.
+               // Figure out which ID field to use
                if ( in_array( 'recentchanges', $tables ) ) {
                        $join_cond = 'ct_rc_id=rc_id';
                } elseif ( in_array( 'logging', $tables ) ) {
@@ -683,7 +691,13 @@ class ChangeTags {
 
                        $tables[] = 'change_tag';
                        $join_conds['change_tag'] = [ 'INNER JOIN', $join_cond ];
-                       $conds['ct_tag'] = explode( '|', $filter_tag );
+                       $conds['ct_tag'] = $filter_tag;
+                       if (
+                               is_array( $filter_tag ) && count( $filter_tag ) > 1 &&
+                               !in_array( 'DISTINCT', $options )
+                       ) {
+                               $options[] = 'DISTINCT';
+                       }
                }
        }
 
@@ -962,7 +976,7 @@ class ChangeTags {
 
                // tags cannot contain commas (used as a delimiter in tag_summary table),
                // pipe (used as a delimiter between multiple tags in
-               // modifyDisplayQuery), or slashes (would break tag description messages in
+               // SpecialRecentchanges and friends), or slashes (would break tag description messages in
                // MediaWiki namespace)
                if ( strpos( $tag, ',' ) !== false || strpos( $tag, '|' ) !== false
                        || strpos( $tag, '/' ) !== false ) {
index a05900b..1248007 100644 (file)
@@ -429,13 +429,14 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
                $fields[] = 'page_latest';
                $join_conds['page'] = [ 'LEFT JOIN', 'rc_cur_id=page_id' ];
 
+               $tagFilter = $opts['tagfilter'] ? explode( '|', $opts['tagfilter'] ) : [];
                ChangeTags::modifyDisplayQuery(
                        $tables,
                        $fields,
                        $conds,
                        $join_conds,
                        $query_options,
-                       $opts['tagfilter']
+                       $tagFilter
                );
 
                if ( !$this->runMainQueryHook( $tables, $fields, $conds, $query_options, $join_conds,
@@ -448,13 +449,24 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
                        return false;
                }
 
+               $orderByAndLimit = [
+                       'ORDER BY' => 'rc_timestamp DESC',
+                       'LIMIT' => $opts['limit']
+               ];
+               if ( in_array( 'DISTINCT', $query_options ) ) {
+                       // ChangeTags::modifyDisplayQuery() adds DISTINCT when filtering on multiple tags.
+                       // In order to prevent DISTINCT from causing query performance problems,
+                       // we have to GROUP BY the primary key. This in turn requires us to add
+                       // the primary key to the end of the ORDER BY, and the old ORDER BY to the
+                       // start of the GROUP BY
+                       $orderByAndLimit['ORDER BY'] = 'rc_timestamp DESC, rc_id DESC';
+                       $orderByAndLimit['GROUP BY'] = 'rc_timestamp, rc_id';
+               }
                // array_merge() is used intentionally here so that hooks can, should
                // they so desire, override the ORDER BY / LIMIT condition(s); prior to
                // MediaWiki 1.26 this used to use the plus operator instead, which meant
                // that extensions weren't able to change these conditions
-               $query_options = array_merge( [
-                       'ORDER BY' => 'rc_timestamp DESC',
-                       'LIMIT' => $opts['limit'] ], $query_options );
+               $query_options = array_merge( $orderByAndLimit, $query_options );
                $rows = $dbr->select(
                        $tables,
                        $fields,
index b3b9210..fee336e 100644 (file)
@@ -103,15 +103,33 @@ class SpecialRecentChangesLinked extends SpecialRecentChanges {
                        $join_conds['page'] = [ 'LEFT JOIN', 'rc_cur_id=page_id' ];
                        $select[] = 'page_latest';
                }
+
+               $tagFilter = $opts['tagfilter'] ? explode( '|', $opts['tagfilter'] ) : [];
                ChangeTags::modifyDisplayQuery(
                        $tables,
                        $select,
                        $conds,
                        $join_conds,
                        $query_options,
-                       $opts['tagfilter']
+                       $tagFilter
                );
 
+               if ( $dbr->unionSupportsOrderAndLimit() ) {
+                       if ( count( $tagFilter ) > 1 ) {
+                               // ChangeTags::modifyDisplayQuery() will have added DISTINCT.
+                               // To prevent this from causing query performance problems, we need to add
+                               // a GROUP BY, and add rc_id to the ORDER BY.
+                               $order = [
+                                       'GROUP BY' => 'rc_timestamp, rc_id',
+                                       'ORDER BY' => 'rc_timestamp DESC, rc_id DESC'
+                               ];
+                       } else {
+                               $order = [ 'ORDER BY' => 'rc_timestamp DESC' ];
+                       }
+               } else {
+                       $order = [];
+               }
+
                if ( !$this->runMainQueryHook( $tables, $select, $conds, $query_options, $join_conds,
                        $opts )
                ) {
@@ -181,12 +199,6 @@ class SpecialRecentChangesLinked extends SpecialRecentChanges {
                                }
                        }
 
-                       if ( $dbr->unionSupportsOrderAndLimit() ) {
-                               $order = [ 'ORDER BY' => 'rc_timestamp DESC' ];
-                       } else {
-                               $order = [];
-                       }
-
                        $query = $dbr->selectSQLText(
                                array_merge( $tables, [ $link_table ] ),
                                $select,
index a602c32..3281735 100644 (file)
                } );
 
                // Collect views
-               allViews = {
+               allViews = $.extend( true, {
                        'default': {
                                title: mw.msg( 'rcfilters-filterlist-title' ),
                                groups: filterGroups
                        }
-               };
-
-               if ( views && mw.config.get( 'wgStructuredChangeFiltersEnableExperimentalViews' ) ) {
-                       // If we have extended views, add them in
-                       $.extend( true, allViews, views );
-               }
+               }, views );
 
                // Go over all views
                $.each( allViews, function ( viewName, viewData ) {
index 5ebec27..3b8ebbd 100644 (file)
@@ -35,6 +35,7 @@
                        items = [],
                        uri = new mw.Uri(),
                        $changesList = $( '.mw-changeslist' ).first().contents(),
+                       experimentalViews = mw.config.get( 'wgStructuredChangeFiltersEnableExperimentalViews' ),
                        createFilterDataFromNumber = function ( num, convertedNumForLabel ) {
                                return {
                                        name: String( num ),
@@ -43,7 +44,7 @@
                        };
 
                // Prepare views
-               if ( namespaceStructure ) {
+               if ( namespaceStructure && experimentalViews ) {
                        items = [];
                        $.each( namespaceStructure, function ( namespaceID, label ) {
                                // Build and clean up the individual namespace items definition
@@ -74,7 +75,7 @@
                                } ]
                        };
                }
-               if ( tagList ) {
+               if ( tagList && experimentalViews ) {
                        views.tags = {
                                title: mw.msg( 'rcfilters-view-tags' ),
                                trigger: '#',
index 9da3f8c..4263c51 100644 (file)
                        $( '.rcfilters-container' ).append( filtersWidget.$element );
                        $( 'body' ).append( $overlay );
 
-                       // Set as ready
-                       $( '.rcfilters-head' ).addClass( 'mw-rcfilters-ui-ready' );
-                       $( '.rcfilters-spinner' ).detach();
-
                        $( 'a.mw-helplink' ).attr(
                                'href',
                                'https://www.mediawiki.org/wiki/Special:MyLanguage/Help:New_filters_for_edit_review'
index 305f3f9..9f3b809 100644 (file)
                &:not( .mw-rcfilters-ui-ready ) {
                        opacity: 0.5;
                        pointer-events: none;
+
+                       .rcoptions {
+                               display: none;
+                       }
                }
        }
 
                margin: 0;
        }
 
-       .mw-changeslist-empty {
-               // Hide the 'empty' message when we load rcfilters
-               // since we replace it anyways with a specific
-               // message of our own
-               display: none;
+       .mw-changeslist {
+               &-empty {
+                       // Hide the 'empty' message when we load rcfilters
+                       // since we replace it anyways with a specific
+                       // message of our own
+                       display: none;
+               }
+
+               &:not( .mw-rcfilters-ui-ready ) {
+                       opacity: 0.5;
+               }
        }
 
        .rcfilters-spinner {
                margin: -2em auto 0;
                width: 70px;
                opacity: 0.8;
-               display: block;
+               display: none;
                white-space: nowrap;
 
+               &:not( .mw-rcfilters-ui-ready ) {
+                       display: block;
+               }
+
                & .rcfilters-spinner-bounce,
                &:before,
                &:after {
index 0e9e843..37dda4d 100644 (file)
@@ -3,7 +3,6 @@
         * List of changes
         *
         * @extends OO.ui.Widget
-        * @mixins OO.ui.mixin.PendingElement
         *
         * @constructor
         * @param {mw.rcfilters.dm.FiltersViewModel} filtersViewModel View model
@@ -23,8 +22,6 @@
 
                // Parent
                mw.rcfilters.ui.ChangesListWrapperWidget.parent.call( this, config );
-               // Mixin constructors
-               OO.ui.mixin.PendingElement.call( this, config );
 
                this.filtersViewModel = filtersViewModel;
                this.changesListViewModel = changesListViewModel;
@@ -51,7 +48,6 @@
        /* Initialization */
 
        OO.inheritClass( mw.rcfilters.ui.ChangesListWrapperWidget, OO.ui.Widget );
-       OO.mixinClass( mw.rcfilters.ui.ChangesListWrapperWidget, OO.ui.mixin.PendingElement );
 
        /**
         * Respond to the highlight feature being toggled on and off
@@ -80,7 +76,9 @@
         * Respond to changes list model invalidate
         */
        mw.rcfilters.ui.ChangesListWrapperWidget.prototype.onModelInvalidate = function () {
-               this.pushPending();
+               $( '.rcfilters-head' ).removeClass( 'mw-rcfilters-ui-ready' );
+               $( '.rcfilters-spinner' ).removeClass( 'mw-rcfilters-ui-ready' );
+               this.$element.removeClass( 'mw-rcfilters-ui-ready' );
        };
 
        /**
                                mw.hook( 'wikipage.content' ).fire( this.$element );
                        }
                }
-               this.popPending();
+
+               $( '.rcfilters-head' ).addClass( 'mw-rcfilters-ui-ready' );
+               $( '.rcfilters-spinner' ).addClass( 'mw-rcfilters-ui-ready' );
+               this.$element.addClass( 'mw-rcfilters-ui-ready' );
        };
 
        /**
index 0abaff2..04ccaf6 100644 (file)
@@ -19,8 +19,6 @@
                mw.rcfilters.ui.FormWrapperWidget.parent.call( this, $.extend( {}, config, {
                        $element: $formRoot
                } ) );
-               // Mixin constructors
-               OO.ui.mixin.PendingElement.call( this, config );
 
                this.changeListModel = changeListModel;
                this.filtersModel = filtersModel;
@@ -48,7 +46,6 @@
        /* Initialization */
 
        OO.inheritClass( mw.rcfilters.ui.FormWrapperWidget, OO.ui.Widget );
-       OO.mixinClass( mw.rcfilters.ui.FormWrapperWidget, OO.ui.mixin.PendingElement );
 
        /**
         * Respond to link click
@@ -89,7 +86,6 @@
         * Respond to model invalidate
         */
        mw.rcfilters.ui.FormWrapperWidget.prototype.onChangesModelInvalidate = function () {
-               this.pushPending();
                this.$submitButton.prop( 'disabled', true );
        };
 
                }
 
                this.cleanUpFieldset();
-
-               this.popPending();
        };
 
        /**
index 8615edc..feed77f 100644 (file)
@@ -1036,6 +1036,9 @@ class ParserTestRunner {
                $linkHolderBatchSize =
                        self::getOptionValue( 'wgLinkHolderBatchSize', $opts, 1000 );
 
+               // Default to fallback skin, but allow it to be overridden
+               $skin = self::getOptionValue( 'skin', $opts, 'fallback' );
+
                $setup = [
                        'wgEnableUploads' => self::getOptionValue( 'wgEnableUploads', $opts, true ),
                        'wgLanguageCode' => $langCode,
@@ -1105,7 +1108,13 @@ class ParserTestRunner {
                $context = RequestContext::getMain();
                $context->setUser( $user );
                $context->setLanguage( $lang );
-               $teardown[] = function () use ( $context ) {
+               // And the skin!
+               $oldSkin = $context->getSkin();
+               $skinFactory = MediaWikiServices::getInstance()->getSkinFactory();
+               $context->setSkin( $skinFactory->makeSkin( $skin ) );
+               $context->setOutput( new OutputPage( $context ) );
+               $setup['wgOut'] = $context->getOutput();
+               $teardown[] = function () use ( $context, $oldSkin ) {
                        // Clear language conversion tables
                        $wrapper = TestingAccessWrapper::newFromObject(
                                $context->getLanguage()->getConverter()
@@ -1114,6 +1123,8 @@ class ParserTestRunner {
                        // Reset context to the restored globals
                        $context->setUser( $GLOBALS['wgUser'] );
                        $context->setLanguage( $GLOBALS['wgContLang'] );
+                       $context->setSkin( $oldSkin );
+                       $context->setOutput( $GLOBALS['wgOut'] );
                };
 
                $teardown[] = $this->executeSetupSnippets( $setup );
diff --git a/tests/phpunit/includes/changetags/ChangeTagsTest.php b/tests/phpunit/includes/changetags/ChangeTagsTest.php
new file mode 100644 (file)
index 0000000..723d685
--- /dev/null
@@ -0,0 +1,247 @@
+<?php
+
+/**
+ * @covers ChangeTags
+ */
+class ChangeTagsTest extends MediaWikiTestCase {
+
+       // TODO only modifyDisplayQuery is tested, nothing else is
+
+       /** @dataProvider provideModifyDisplayQuery */
+       public function testModifyDisplayQuery( $origQuery, $filter_tag, $useTags, $modifiedQuery ) {
+               $this->setMwGlobals( 'wgUseTagFilter', $useTags );
+               // HACK resolve deferred group concats (see comment in provideModifyDisplayQuery)
+               if ( isset( $modifiedQuery['fields']['ts_tags'] ) ) {
+                       $modifiedQuery['fields']['ts_tags'] = call_user_func_array(
+                               [ wfGetDB( DB_REPLICA ), 'buildGroupConcatField' ],
+                               $modifiedQuery['fields']['ts_tags']
+                       );
+               }
+               if ( isset( $modifiedQuery['exception'] ) ) {
+                       $this->setExpectedException( $modifiedQuery['exception'] );
+               }
+               ChangeTags::modifyDisplayQuery(
+                       $origQuery['tables'],
+                       $origQuery['fields'],
+                       $origQuery['conds'],
+                       $origQuery['join_conds'],
+                       $origQuery['options'],
+                       $filter_tag
+               );
+               if ( !isset( $modifiedQuery['exception'] ) ) {
+                       $this->assertArrayEquals(
+                               $modifiedQuery,
+                               $origQuery,
+                               /* ordered = */ false,
+                               /* named = */ true
+                       );
+               }
+       }
+
+       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
+               $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' ],
+               ];
+
+               return [
+                       'simple recentchanges query' => [
+                               [
+                                       'tables' => [ 'recentchanges' ],
+                                       'fields' => [ 'rc_id', 'rc_timestamp' ],
+                                       'conds' => [ "rc_timestamp > '20170714183203'" ],
+                                       'join_conds' => [],
+                                       'options' => [ 'ORDER BY' => 'rc_timestamp DESC' ],
+                               ],
+                               '', // no tag filter
+                               true, // tag filtering enabled
+                               [
+                                       'tables' => [ 'recentchanges' ],
+                                       'fields' => [ 'rc_id', 'rc_timestamp', 'ts_tags' => $groupConcats['recentchanges'] ],
+                                       'conds' => [ "rc_timestamp > '20170714183203'" ],
+                                       'join_conds' => [],
+                                       'options' => [ 'ORDER BY' => 'rc_timestamp DESC' ],
+                               ]
+                       ],
+                       'simple query with strings' => [
+                               [
+                                       'tables' => 'recentchanges',
+                                       'fields' => 'rc_id',
+                                       'conds' => "rc_timestamp > '20170714183203'",
+                                       'join_conds' => [],
+                                       'options' => 'ORDER BY rc_timestamp DESC',
+                               ],
+                               '', // no tag filter
+                               true, // tag filtering enabled
+                               [
+                                       'tables' => [ 'recentchanges' ],
+                                       'fields' => [ 'rc_id', 'ts_tags' => $groupConcats['recentchanges'] ],
+                                       'conds' => [ "rc_timestamp > '20170714183203'" ],
+                                       'join_conds' => [],
+                                       'options' => [ 'ORDER BY rc_timestamp DESC' ],
+                               ]
+                       ],
+                       'recentchanges query with single tag filter' => [
+                               [
+                                       'tables' => [ 'recentchanges' ],
+                                       'fields' => [ 'rc_id', 'rc_timestamp' ],
+                                       'conds' => [ "rc_timestamp > '20170714183203'" ],
+                                       'join_conds' => [],
+                                       'options' => [ 'ORDER BY' => 'rc_timestamp DESC' ],
+                               ],
+                               'foo',
+                               true, // tag filtering enabled
+                               [
+                                       'tables' => [ 'recentchanges', 'change_tag' ],
+                                       'fields' => [ 'rc_id', 'rc_timestamp', 'ts_tags' => $groupConcats['recentchanges'] ],
+                                       'conds' => [ "rc_timestamp > '20170714183203'", 'ct_tag' => 'foo' ],
+                                       'join_conds' => [ 'change_tag' => [ 'INNER JOIN', 'ct_rc_id=rc_id' ] ],
+                                       'options' => [ 'ORDER BY' => 'rc_timestamp DESC' ],
+                               ]
+                       ],
+                       'logging query with single tag filter and strings' => [
+                               [
+                                       'tables' => 'logging',
+                                       'fields' => 'log_id',
+                                       'conds' => "log_timestamp > '20170714183203'",
+                                       'join_conds' => [],
+                                       'options' => 'ORDER BY log_timestamp DESC',
+                               ],
+                               'foo',
+                               true, // tag filtering enabled
+                               [
+                                       'tables' => [ 'logging', 'change_tag' ],
+                                       'fields' => [ 'log_id', 'ts_tags' => $groupConcats['logging'] ],
+                                       'conds' => [ "log_timestamp > '20170714183203'", 'ct_tag' => 'foo' ],
+                                       'join_conds' => [ 'change_tag' => [ 'INNER JOIN', 'ct_log_id=log_id' ] ],
+                                       'options' => [ 'ORDER BY log_timestamp DESC' ],
+                               ]
+                       ],
+                       'revision query with single tag filter' => [
+                               [
+                                       'tables' => [ 'revision' ],
+                                       'fields' => [ 'rev_id', 'rev_timestamp' ],
+                                       'conds' => [ "rev_timestamp > '20170714183203'" ],
+                                       'join_conds' => [],
+                                       'options' => [ 'ORDER BY' => 'rev_timestamp DESC' ],
+                               ],
+                               'foo',
+                               true, // tag filtering enabled
+                               [
+                                       'tables' => [ 'revision', 'change_tag' ],
+                                       'fields' => [ 'rev_id', 'rev_timestamp', 'ts_tags' => $groupConcats['revision'] ],
+                                       'conds' => [ "rev_timestamp > '20170714183203'", 'ct_tag' => 'foo' ],
+                                       'join_conds' => [ 'change_tag' => [ 'INNER JOIN', 'ct_rev_id=rev_id' ] ],
+                                       'options' => [ 'ORDER BY' => 'rev_timestamp DESC' ],
+                               ]
+                       ],
+                       'archive query with single tag filter' => [
+                               [
+                                       'tables' => [ 'archive' ],
+                                       'fields' => [ 'ar_id', 'ar_timestamp' ],
+                                       'conds' => [ "ar_timestamp > '20170714183203'" ],
+                                       'join_conds' => [],
+                                       'options' => [ 'ORDER BY' => 'ar_timestamp DESC' ],
+                               ],
+                               'foo',
+                               true, // tag filtering enabled
+                               [
+                                       'tables' => [ 'archive', 'change_tag' ],
+                                       'fields' => [ 'ar_id', 'ar_timestamp', 'ts_tags' => $groupConcats['archive'] ],
+                                       'conds' => [ "ar_timestamp > '20170714183203'", 'ct_tag' => 'foo' ],
+                                       'join_conds' => [ 'change_tag' => [ 'INNER JOIN', 'ct_rev_id=ar_rev_id' ] ],
+                                       'options' => [ 'ORDER BY' => 'ar_timestamp DESC' ],
+                               ]
+                       ],
+                       'unsupported table name throws exception (even without tag filter)' => [
+                               [
+                                       'tables' => [ 'foobar' ],
+                                       'fields' => [ 'fb_id', 'fb_timestamp' ],
+                                       'conds' => [ "fb_timestamp > '20170714183203'" ],
+                                       'join_conds' => [],
+                                       'options' => [ 'ORDER BY' => 'fb_timestamp DESC' ],
+                               ],
+                               '',
+                               true, // tag filtering enabled
+                               [ 'exception' => MWException::class ]
+                       ],
+                       'tag filter ignored when tag filtering is disabled' => [
+                               [
+                                       'tables' => [ 'archive' ],
+                                       'fields' => [ 'ar_id', 'ar_timestamp' ],
+                                       'conds' => [ "ar_timestamp > '20170714183203'" ],
+                                       'join_conds' => [],
+                                       'options' => [ 'ORDER BY' => 'ar_timestamp DESC' ],
+                               ],
+                               'foo',
+                               false, // tag filtering disabled
+                               [
+                                       'tables' => [ 'archive' ],
+                                       'fields' => [ 'ar_id', 'ar_timestamp', 'ts_tags' => $groupConcats['archive'] ],
+                                       'conds' => [ "ar_timestamp > '20170714183203'" ],
+                                       'join_conds' => [],
+                                       'options' => [ 'ORDER BY' => 'ar_timestamp DESC' ],
+                               ]
+                       ],
+                       'recentchanges query with multiple tag filter' => [
+                               [
+                                       'tables' => [ 'recentchanges' ],
+                                       'fields' => [ 'rc_id', 'rc_timestamp' ],
+                                       'conds' => [ "rc_timestamp > '20170714183203'" ],
+                                       'join_conds' => [],
+                                       'options' => [ 'ORDER BY' => 'rc_timestamp DESC' ],
+                               ],
+                               [ 'foo', 'bar' ],
+                               true, // tag filtering enabled
+                               [
+                                       'tables' => [ 'recentchanges', 'change_tag' ],
+                                       'fields' => [ 'rc_id', 'rc_timestamp', 'ts_tags' => $groupConcats['recentchanges'] ],
+                                       'conds' => [ "rc_timestamp > '20170714183203'", 'ct_tag' => [ 'foo', 'bar' ] ],
+                                       'join_conds' => [ 'change_tag' => [ 'INNER JOIN', 'ct_rc_id=rc_id' ] ],
+                                       'options' => [ 'ORDER BY' => 'rc_timestamp DESC', 'DISTINCT' ],
+                               ]
+                       ],
+                       'recentchanges query with multiple tag filter that already has DISTINCT' => [
+                               [
+                                       'tables' => [ 'recentchanges' ],
+                                       'fields' => [ 'rc_id', 'rc_timestamp' ],
+                                       'conds' => [ "rc_timestamp > '20170714183203'" ],
+                                       'join_conds' => [],
+                                       'options' => [ 'DISTINCT', 'ORDER BY' => 'rc_timestamp DESC' ],
+                               ],
+                               [ 'foo', 'bar' ],
+                               true, // tag filtering enabled
+                               [
+                                       'tables' => [ 'recentchanges', 'change_tag' ],
+                                       'fields' => [ 'rc_id', 'rc_timestamp', 'ts_tags' => $groupConcats['recentchanges'] ],
+                                       'conds' => [ "rc_timestamp > '20170714183203'", 'ct_tag' => [ 'foo', 'bar' ] ],
+                                       'join_conds' => [ 'change_tag' => [ 'INNER JOIN', 'ct_rc_id=rc_id' ] ],
+                                       'options' => [ 'DISTINCT', 'ORDER BY' => 'rc_timestamp DESC' ],
+                               ]
+                       ],
+                       'recentchanges query with multiple tag filter with strings' => [
+                               [
+                                       'tables' => 'recentchanges',
+                                       'fields' => 'rc_id',
+                                       'conds' => "rc_timestamp > '20170714183203'",
+                                       'join_conds' => [],
+                                       'options' => 'ORDER BY rc_timestamp DESC',
+                               ],
+                               [ 'foo', 'bar' ],
+                               true, // tag filtering enabled
+                               [
+                                       'tables' => [ 'recentchanges', 'change_tag' ],
+                                       'fields' => [ 'rc_id', 'ts_tags' => $groupConcats['recentchanges'] ],
+                                       'conds' => [ "rc_timestamp > '20170714183203'", 'ct_tag' => [ 'foo', 'bar' ] ],
+                                       'join_conds' => [ 'change_tag' => [ 'INNER JOIN', 'ct_rc_id=rc_id' ] ],
+                                       'options' => [ 'ORDER BY rc_timestamp DESC', 'DISTINCT' ],
+                               ]
+                       ],
+               ];
+       }
+
+}