Mattflaschen has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/350968 )
Change subject: Fix FlaggedRevs RC (RecentChanges and Watchlist) line
indications
......................................................................
Fix FlaggedRevs RC (RecentChanges and Watchlist) line indications
We need to do all the queries unconditionally, except that
the actual hidden rows are only done with hideReviewed
The others are used for links and/or indications on the rows
(e.g. [pending edits] link and [unchecked page] text)
Bug: T164049
Change-Id: Id4541c618c163e7b898e6a5bfb4b2551b14df432
---
M FlaggedRevs.php
M frontend/FlaggedRevsUI.hooks.php
2 files changed, 68 insertions(+), 12 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/FlaggedRevs
refs/changes/68/350968/1
diff --git a/FlaggedRevs.php b/FlaggedRevs.php
index 978cdeb..91a8e0b 100644
--- a/FlaggedRevs.php
+++ b/FlaggedRevs.php
@@ -573,6 +573,7 @@
$wgHooks['PageHistoryPager::getQueryInfo'][] =
'FlaggedRevsUIHooks::addToHistQuery';
$wgHooks['PageHistoryLineEnding'][] = 'FlaggedRevsUIHooks::addToHistLine';
# Select extra info & filter items on Special:NewPages
+$wgHooks['ChangesListSpecialPageQuery'][] =
'FlaggedRevsUIHooks::modifyChangesListSpecialPageQuery';
$wgHooks['SpecialNewpagesConditions'][] =
'FlaggedRevsUIHooks::modifyNewPagesQuery';
# Mark items in RC
$wgHooks['ChangesListInsertArticleLink'][] =
'FlaggedRevsUIHooks::addToChangeListLine';
diff --git a/frontend/FlaggedRevsUI.hooks.php b/frontend/FlaggedRevsUI.hooks.php
index 9ec6dc5..0a72273 100644
--- a/frontend/FlaggedRevsUI.hooks.php
+++ b/frontend/FlaggedRevsUI.hooks.php
@@ -317,12 +317,9 @@
'queryCallable' => function (
$specialClassName, $ctx, $dbr, &$tables,
&$fields, &$conds,
&$query_options, &$join_conds ) {
- return
FlaggedRevsUIHooks::modifyChangesListQuery(
- $conds,
- $tables,
-
$join_conds,
- $fields
- );
+
FlaggedRevsUIHooks::hideReviewedChangesUnconditionally(
+ $conds
+ );
},
],
],
@@ -399,22 +396,80 @@
public static function modifyNewPagesQuery(
$specialPage, $opts, &$conds, &$tables, &$fields, &$join_conds
) {
- return self::modifyChangesListQuery( $conds, $tables,
$join_conds, $fields );
+ self::makeAllQueryChanges( $conds, $tables, $join_conds,
$fields );
+
+ return true;
}
- public static function modifyChangesListQuery(
+ public static function modifyChangesListSpecialPageQuery(
+ $name, &$tables, &$fields, &$conds, &$query_options,
&$join_conds, $opts ) {
+
+ self::addMetadataQueryJoins( $tables, $join_conds, $fields );
+ }
+
+ /**
+ * Make all query changes, both joining for FlaggedRevs metadata and
conditionally
+ * hiding reviewed changes
+ *
+ * @param array &$conds Query conditions
+ * @param array &$tables Tables to query
+ * @param array &$join_conds Query join conditions
+ * @param array &$fields Fields to query
+ */
+ public static function makeAllQueryChanges(
array &$conds, array &$tables, array &$join_conds, array
&$fields
) {
- global $wgRequest;
+ self::addMetadataQueryJoins( $tables, $join_conds, $fields );
+ self::hideReviewedChangesIfNeeded( $conds );
+ }
+
+ /**
+ * Add FlaggedRevs metadata by adding fields and joins
+ *
+ * @param array &$conds Query conditions
+ * @param array &$tables Tables to query
+ * @param array &$join_conds Query join conditions
+ * @param array &$fields Fields to query
+ */
+ public static function addMetadataQueryJoins(
+ array &$tables, array &$join_conds, array &$fields
+ ) {
$tables[] = 'flaggedpages';
$fields[] = 'fp_stable';
$fields[] = 'fp_pending_since';
$join_conds['flaggedpages'] = [ 'LEFT JOIN', 'fp_page_id =
rc_cur_id' ];
+ }
+
+ /**
+ * Checks the request variable and hides reviewed changes if requested
+ *
+ * Must already be joined into the FlaggedRevs tables.
+ *
+ * @param array &$conds Query conditions
+ */
+ public static function hideReviewedChangesIfNeeded(
+ array &$conds
+ ) {
+ global $wgRequest;
+
if ( $wgRequest->getBool( 'hideReviewed' ) &&
!FlaggedRevs::useSimpleConfig() ) {
- // Don't filter external changes as FlaggedRevisions
doesn't apply to those
- $conds[] = 'rc_timestamp >= fp_pending_since OR
fp_stable IS NULL OR rc_type = ' . RC_EXTERNAL;
+ self::hideReviewedChangesUnconditionally( $conds );
}
- return true;
+ }
+
+ /**
+ * Hides reviewed changes unconditionally; assumes you have checked
whether to do
+ * so already
+ *
+ * Must already be joined into the FlaggedRevs tables.
+ *
+ * @param array &$conds Query conditions
+ */
+ public static function hideReviewedChangesUnconditionally(
+ array &$conds
+ ) {
+ // Don't filter external changes as FlaggedRevisions doesn't
apply to those
+ $conds[] = 'rc_timestamp >= fp_pending_since OR fp_stable IS
NULL OR rc_type = ' . RC_EXTERNAL;
}
public static function addToHistLine( HistoryPager $history, $row, &$s,
&$liClasses ) {
--
To view, visit https://gerrit.wikimedia.org/r/350968
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id4541c618c163e7b898e6a5bfb4b2551b14df432
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/FlaggedRevs
Gerrit-Branch: master
Gerrit-Owner: Mattflaschen <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits