jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/374831 )
Change subject: WLFilters: fix server-side tag filtering ...................................................................... WLFilters: fix server-side tag filtering Tag filtering was enabled in the UI but the backend was not properly wired for it. Change-Id: I1c50b67b0a4aaddb561e79fdacd9849ffe0ded8c --- M includes/specialpage/ChangesListSpecialPage.php M includes/specials/SpecialRecentchanges.php M includes/specials/SpecialWatchlist.php 3 files changed, 20 insertions(+), 6 deletions(-) Approvals: Mattflaschen: Looks good to me, approved jenkins-bot: Verified diff --git a/includes/specialpage/ChangesListSpecialPage.php b/includes/specialpage/ChangesListSpecialPage.php index 4d27d35..acd5d14 100644 --- a/includes/specialpage/ChangesListSpecialPage.php +++ b/includes/specialpage/ChangesListSpecialPage.php @@ -904,6 +904,7 @@ $opts->add( 'invert', false ); $opts->add( 'associated', false ); $opts->add( 'urlversion', 1 ); + $opts->add( 'tagfilter', '' ); return $opts; } diff --git a/includes/specials/SpecialRecentchanges.php b/includes/specials/SpecialRecentchanges.php index 6ee697e..547a1b0 100644 --- a/includes/specials/SpecialRecentchanges.php +++ b/includes/specials/SpecialRecentchanges.php @@ -241,7 +241,6 @@ $opts->add( 'categories', '' ); $opts->add( 'categories_any', false ); - $opts->add( 'tagfilter', '' ); return $opts; } diff --git a/includes/specials/SpecialWatchlist.php b/includes/specials/SpecialWatchlist.php index 0dd66b0..07889b7 100644 --- a/includes/specials/SpecialWatchlist.php +++ b/includes/specials/SpecialWatchlist.php @@ -382,10 +382,6 @@ $tables = array_merge( [ 'recentchanges', 'watchlist' ], $tables ); $fields = array_merge( RecentChange::selectFields(), $fields ); - $query_options = array_merge( [ - 'ORDER BY' => 'rc_timestamp DESC', - 'LIMIT' => $opts['limit'] - ], $query_options ); $join_conds = array_merge( [ 'watchlist' => [ @@ -422,13 +418,14 @@ ], LIST_OR ); } + $tagFilter = $opts['tagfilter'] ? explode( '|', $opts['tagfilter'] ) : []; ChangeTags::modifyDisplayQuery( $tables, $fields, $conds, $join_conds, $query_options, - '' + $tagFilter ); $this->runMainQueryHook( $tables, $fields, $conds, $query_options, $join_conds, $opts ); @@ -437,6 +434,23 @@ 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) + $query_options = array_merge( $orderByAndLimit, $query_options ); + return $dbr->select( $tables, $fields, -- To view, visit https://gerrit.wikimedia.org/r/374831 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I1c50b67b0a4aaddb561e79fdacd9849ffe0ded8c Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Sbisson <sbis...@wikimedia.org> Gerrit-Reviewer: Florianschmidtwelzow <florian.schmidt.stargatewis...@gmail.com> Gerrit-Reviewer: Mattflaschen <mflasc...@wikimedia.org> Gerrit-Reviewer: Sbisson <sbis...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits