Mattflaschen has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/375047 )
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
(cherry picked from commit 467fbef034601ed172cbc643a633c18e5f69a2b6)
---
M includes/specialpage/ChangesListSpecialPage.php
M includes/specials/SpecialRecentchanges.php
M includes/specials/SpecialWatchlist.php
3 files changed, 20 insertions(+), 6 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/47/375047/1
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 d6eac32..919e0e2 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 94b36b9..cc715ab 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/375047
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I1c50b67b0a4aaddb561e79fdacd9849ffe0ded8c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: wmf/1.30.0-wmf.16
Gerrit-Owner: Mattflaschen <[email protected]>
Gerrit-Reviewer: Sbisson <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits