There is no way to express that Title::castFromPageIdentity(),
Title::castFromPageReference() and Title::castFromLinkTarget()
can only return null when the parameter is null. We need to add
Phan suppressions or explicit types almost everywhere that these
methods are used with parameters that are known to not be null.
Instead, introduce new methods Title::newFromPageIdentity() and
Title::newFromPageReference() (Title::newFromLinkTarget() already
exists), without the null-coalescing behavior, and use them when
the parameter is not null. This lets static analysis tools, and
humans, easily understand where nulls can't appear.
Do the same with the corresponding TitleFactory methods.
Change the obvious uses of castFrom*() to newFrom*() (if there is
a Phan suppression, a type check, or a method call on the result).
Change-Id: Ida4da75953cf3bca372a40dc88022443109ca0cb
To follow Message. This is approved as part of RFC T166010.
Also namespace it but doing it properly with PSR-4 would require
namespacing every class under language/ and that will take some time.
Bug: T321882
Change-Id: I195cf4c67bd51410556c2dd1e33cc9c1033d5d18
We already depend on this behavior in IndexPager::getNavigationBuilder(),
but it wasn't allowed by the type hints and wasn't covered by tests.
Change-Id: I9343e852dc4610a50adf1c22ed429ec0a40da816
Follow-up to Ic75bd597b210e14612ca3aebb531b659897e8294.
No longer needed after I161dc0159e4372e3478341ee3fbea13b723d9fc1.
This is a public method, but it has not been included in a release
yet, so we can remove it without deprecation.
Change-Id: Ie5eea4d3423136812178747e187771e7cf78e95f
Extensions like CheckUser expect IndexPager::makeLink() to be used for
displaying the navigation links of the pager, and it was marked as
'@stable to override'.
If IndexPager::makeLink() is overridden, it will be called instead of
PagerNavigationBuilder::makeLink(). This behavior is considered
deprecated.
Also mark PagerNavigationBuilder::makeLink() as protected and
'@stable to override', to provide a migration path. Users can now
override IndexPager::getNavigationBuilder() to return a subclass
of PagerNavigationBuilder, and override makeLink() on that subclass.
Follow-Up: cfd6ffe7bb
Bug: T317477
Change-Id: I4e2f36b543462aa5d852733da650fb70d49ebf06
We had several implementations of almost identical paging links:
* PrevNextNavigationRenderer: The nicest one, somewhat recently added
(4ca72763ec). Unfortunately it was also the least featureful: only
supporting paging by numeric offset and not by index, and not able
to generate "first"/"last" links. Also, I didn't realize that it
exists when working on 94553a1bcb and b95d208340, so it was missing
those changes too.
* IndexPager/ReverseChronologicalPager/AlphabeticPager: These have
been here forever. The most featureful, but not configurable, so
a large part of the implementation was copy-pasted in two classes.
* SpecialWhatLinksHere: Through some accident of history, this one
special page ended up with its own implementation???
They are all replaced to use the new PagerNavigationBuilder.
It may be slightly too much, but I had fun writing it.
Notable changes compared to PrevNextNavigationRenderer:
* Adds <div class="mw-pager-navigation-bar"> wrapper around the
navigation and <span class="…"> wrappers on inactive links
* The current limit link is made inactive
(like the "prev" link when on first page, etc.)
Notable changes compared to ...Pager/...Pager/...Pager:
* Does not generate useless tooltips that contain only the
title of the page, can use custom tooltips
* The current limit link is made inactive
(like the "prev" link when on first page, etc.)
* All links have query parameters in a consistent order:
?title= &... &dir= &offset= &limit= (some of them are optional)
These changes affect many special pages and actions. I tested on:
* Special:Contributions (ReverseChronologicalPager)
* action=history (ReverseChronologicalPager)
* Special:Categories (AlphabeticPager)
* Special:WantedPages (PrevNextNavigationRenderer)
* Special:Search (PrevNextNavigationRenderer)
* Special:WhatLinksHere
Bug: T308364
Change-Id: Ic75bd597b210e14612ca3aebb531b659897e8294
Refactored buildPrevNextNavigation() into standalone helper class,
PrevNextNavigationRenderer, to be used by both SpecialPages and Pagers.
Bug:T207977
Change-Id: Ic49837a451f795ec203e867961ec1c69075cc91a