Page MenuHomePhabricator

Refactor IndexPager and Navigation builder to allow multiple pagers on one page
Open, Needs TriagePublic

Description

The navigation of pagers currently has hardcoded values for paging queries, this means that having multiple pagers in a single page is impossible as they cannot discern which of the pagers triggered a page change.

We require this capability for T382250 but first some investigation must be done to make sure that doing this won't break existing functionality.

Event Timeline

@matmarex I believe you wrote the PagerNavigationBuilder, Can you see any potential pitfalls with this?

No objections from me. It seems that PagerNavigationBuilder won't even need any changes, since it already allow customizing all of the query parameter names. Only IndexPager::getNavigationBuilder() and the related methods need some updates to allow them to be customized (maybe moving the strings to constants that can be overridden in subclasses, or something).

A few thoughts on this:

  • Moving these names to a constant/declarative method seems a good idea in principle. Constants would be the simplest, I think.
  • I also considered adding a method that would allow subclasses to specify a prefix (or suffix) for all the relevant parameters. This has the advantage of not requiring subclasses to change if the list of parameters is changed; and it generally hides these parameters from subclasses. The problem is, subclasses might need the parameter names to do stuff, and obtaining the full name given only the prefix would be awkward at the very least.
  • There seem to be a bunch of pager classes that could use the newly-introduced constants instead of hardcoding parameter names. Fixing these is not required, except for the public interfaces in core (IndexPager, TablePager, CodexTablePager, perhaps ContributionsPager. The problem with hardcoded strings is that we can't deprecate them, but we could perhaps add a line to the release notes.
  • One thing that complicates this refactoring is WebRequest::getLimitOffsetForUser(), which hardcodes both the 'limit' and 'offset' parameters. Clearly it would be easy enough to add two parameters to override these names, but that doesn't help with the fact that this method doesn't belong in WebRequest. It might be a good time to move it elsewhere, but where? I think it only has a purpose in classes that deal with pagination; the problem being, these classes don't necessarily have a common ancestor (SpecialPage and IndexPager being the two most common). Perhaps it could be moved to a new trait?
    • I'm also generally really concerned about what other places might be making the assumption that 'limit' and 'offset' always have these names. And this is for everything from MediaWiki code to the CDN (for example, if there are rules to detect expensive queries).
Daimona subscribed.

Unassigning myself for the time being: we're trying to wrap up the work on T382018 this week, and this task is larger than what I'm comfortable doing with such a tight schedule. We also do not consider this task a blocker for that work, hence removing from the sprint board (but still leaving tagged with Campaigns-Product-Team as we'll probably want to do this at some point.