Page MenuHomePhabricator

SpecialRecentChangesFilters hook is not executed for feeds
Closed, ResolvedPublic

Description

When using the SpecialRecentChangesFilters [1] and SpecialRecentChangesQuery [2] hooks to enhance the recent changes, the former is never called when recent changes are displayed as a feed. This can cause exceptions when trying to access the value of filter options in the query hook.

In SpecialRecentChanges::getOptions [3] a special setup method for feeds is called when a feed output was requested. It seems that this was previously done to have some better caching for feeds; that however was removed later [4]. In any way, there is not much difference to the normal setup method, except that custom filters [5] are not added.

Nothing in the hook descriptions however suggests that this is the case, and given that the hook is the only way to modify the default options [6], I strongly suggest that the custom filters are added in the feedSetup method as well.

And at that point, merging the two setup functions should be considered. The only thing that really differs then would be the feed limit—which can be just respected by doing the check with $isFeed inside the setup method—and that subpage behavior which is not triggered anyway when no parameters are passed to the setup function.

In any way, not adding the custom filters in the feed setup breaks the extension setup and requires a further check inside the SpecialRecentChangesQuery hook handler to ensure that the option exists. I.e. something like this:

if (!$opts->validateName('optionname')) {
    global $wgDefaultUserOptions;
    $opts->add('optionname', $wgDefaultUserOptions['rcoptionname']);
}

[1]: https://www.mediawiki.org/wiki/Manual:Hooks/SpecialRecentChangesFilters
[2]: https://www.mediawiki.org/wiki/Manual:Hooks/SpecialRecentChangesQuery
[3]: https://git.wikimedia.org/blob/mediawiki%2Fcore.git/d7379debd2bd61fda592c144e6574bf99ed60e83/includes%2Fspecials%2FSpecialRecentchanges.php#L132
[4]: https://git.wikimedia.org/commit/mediawiki%2Fcore.git/52b59f06859c337a56b10bb0171d199b19688773
[5]: https://git.wikimedia.org/blob/mediawiki%2Fcore.git/d7379debd2bd61fda592c144e6574bf99ed60e83/includes%2Fspecials%2FSpecialRecentchanges.php#L99
[6]: https://git.wikimedia.org/blob/mediawiki%2Fcore.git/d7379debd2bd61fda592c144e6574bf99ed60e83/includes%2Fspecials%2FSpecialRecentchanges.php#L42


Version: 1.23.0
Severity: normal

Details

Reference
bz57201

Event Timeline

bzimport raised the priority of this task from to High.
bzimport set Reference to bz57201.
poke created this task.Nov 18 2013, 5:42 PM

Change 96070 had a related patch set uploaded by Poke:
Integrate feed-specific setup into general setup

https://gerrit.wikimedia.org/r/96070

Change 96070 merged by jenkins-bot:
Integrate feed-specific setup into general setup

https://gerrit.wikimedia.org/r/96070

Fix merged, thank you!