From 9efb7a733956b92360def1028db9870c9886d1ac Mon Sep 17 00:00:00 2001 From: Erik Bernhardson Date: Tue, 15 Oct 2013 15:21:34 -0700 Subject: [PATCH] New hook accommodates non-revision rc queries Within Special:RecentChanges the default non-extended query contains ( rc_this_oldid=page_latest OR rc_type=3 ) Wikidata has previously used the SpecialWatchlistQuery hook to look for this exact string and change rc_type=3 to rc_type IN (3,5). Flow is another type of change that doesn't have a matching row in revisions to match page_latest for and needs to be added to this query. This patch adds a new hook, SpecialWatchlistGetNonRevisionTypes, which allows different extensions to add to a list of values for rc_type (or rc_source once 85787 is merged). This will allow multiple extensions to affect the resulting query without them breaking eachother. Change-Id: Id6916fe999c0faa38de878b7b5687e7ea00901bd --- RELEASE-NOTES-1.22 | 3 +++ cache/.htaccess | 0 docs/hooks.txt | 5 +++++ includes/specials/SpecialWatchlist.php | 16 +++++++++++++++- 4 files changed, 23 insertions(+), 1 deletion(-) mode change 100644 => 100755 cache/.htaccess diff --git a/RELEASE-NOTES-1.22 b/RELEASE-NOTES-1.22 index 4cfd6618c4..d6a75bac4c 100644 --- a/RELEASE-NOTES-1.22 +++ b/RELEASE-NOTES-1.22 @@ -253,6 +253,9 @@ production. output in a HTML comment. * The 'UnwatchArticle' and 'WatchArticle' hooks now support a Status object instead of just a boolean return value to abort the hook. +* Added a hook, SpecialWatchlistGetNonRevisionTypes, to allow extensions + with custom recentchanges entries to hook into the Watchlist without + clobbering each other. === Bug fixes in 1.22 === * Disable Special:PasswordReset when $wgEnableEmail is false. Previously one diff --git a/cache/.htaccess b/cache/.htaccess old mode 100644 new mode 100755 diff --git a/docs/hooks.txt b/docs/hooks.txt index 26032cb5b2..5aaf596103 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -2365,6 +2365,11 @@ $special: the special page object &$fields: array of query fields $values: array of variables with watchlist options +'SpecialWatchlistGetNonRevisionTypes': Called when building sql query for +SpecialWatchlist. Allows extensions to register custom values they have +inserted to rc_type so they can be returned as part of the watchlist. +&$nonRevisionTypes: array of values in the rc_type field of recentchanges table + 'TestCanonicalRedirect': Called when about to force a redirect to a canonical URL for a title when we have no other parameters on the URL. Gives a chance for extensions that alter page view behavior radically to abort that redirect or diff --git a/includes/specials/SpecialWatchlist.php b/includes/specials/SpecialWatchlist.php index 11632a38cf..4afa279e7d 100644 --- a/includes/specials/SpecialWatchlist.php +++ b/includes/specials/SpecialWatchlist.php @@ -208,7 +208,21 @@ class SpecialWatchlist extends SpecialPage { $usePage = false; } else { # Top log Ids for a page are not stored - $conds[] = 'rc_this_oldid=page_latest OR rc_type=' . RC_LOG; + $nonRevisionTypes = array( RC_LOG ); + wfRunHooks( 'SpecialWatchlistGetNonRevisionTypes', array( &$nonRevisionTypes ) ); + if ( $nonRevisionTypes ) { + if ( count( $nonRevisionTypes ) === 1 ) { + // if only one use an equality instead of IN condition + $nonRevisionTypes = reset( $nonRevisionTypes ); + } + $conds[] = $dbr->makeList( + array( + 'rc_this_oldid=page_latest', + 'rc_type' => $nonRevisionTypes, + ), + LIST_OR + ); + } $limitWatchlist = 0; $usePage = true; } -- 2.20.1