Commit graph

16 commits

Author SHA1 Message Date
James D. Forrester
eeb5a740b3 Namespace Message, move to appropriate directory
Bug: T353458
Change-Id: I088cbc53fbcdb974e5b05b45a62e91709dacc024
2024-02-14 15:10:36 -05:00
Bartosz Dziewoński
6ba47296d9 Fix Phan suppressions related to Title::castFrom*() and friends
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
2023-04-22 16:45:09 +02:00
Bartosz Dziewoński
1e86517db5 Remove deprecated pager methods/classes
Deprecated in MW 1.39:
* Ic75bd597b210e14612ca3aebb531b659897e8294
* I4e2f36b543462aa5d852733da650fb70d49ebf06

Hard-deprecated in MW 1.40:
* I09e9203b19e3808af9348db8a889d5e118282230

Change-Id: I17bd8f80e87a04674e826d7966aa3ddb011fc7ba
2023-03-22 15:23:56 +00:00
Bartosz Dziewoński
f8367c8c98 Hard-deprecate deprecated pager methods/classes
Deprecated in MW 1.39 in commits:
* Ic75bd597b210e14612ca3aebb531b659897e8294
* I4e2f36b543462aa5d852733da650fb70d49ebf06

Depends-On: I8b3adfe907ae16279ec3d480b7eedec5901884f2
Depends-On: I376361bc86a6085fe94a5439b04239ab123a515c
Change-Id: I09e9203b19e3808af9348db8a889d5e118282230
2023-03-15 16:45:59 +01:00
James D. Forrester
ad06527fb4 Reorg: Namespace the Title class
This is moderately messy.

Process was principally:

* xargs rg --files-with-matches '^use Title;' | grep 'php$' | \
  xargs -P 1 -n 1 sed -i -z 's/use Title;/use MediaWiki\\Title\\Title;/1'
* rg --files-without-match 'MediaWiki\\Title\\Title;' . | grep 'php$' | \
  xargs rg --files-with-matches 'Title\b' | \
  xargs -P 1 -n 1 sed -i -z 's/\nuse /\nuse MediaWiki\\Title\\Title;\nuse /1'
* composer fix

Then manual fix-ups for a few files that don't have any use statements.

Bug: T166010
Follows-Up: Ia5d8cb759dc3bc9e9bbe217d0fb109e2f8c4101a
Change-Id: If8fc9d0d95fc1a114021e282a706fc3e7da3524b
2023-03-02 08:46:53 -05:00
Amir Sarabadani
7d8768e931 Reorg: Move HTML-related classes out of includes/ to Html/
Bug: T321882
Change-Id: I5dc1f7e9c303cd3f5b9dd7010d6bb470d8400a18
2023-02-16 20:40:01 +01:00
Amir Sarabadani
523ab7cff8 Reorg: Move RawMessage to under language/
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
2022-12-16 11:30:19 +01:00
Bartosz Dziewoński
2422e2ae9f PagerNavigationBuilder: Document that nulls in setLinkQuery() etc. are allowed
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
2022-11-02 23:56:35 +00:00
Bartosz Dziewoński
08895be51b pager: Remove unused PagerNavigationBuilder::setExtra()
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
2022-11-02 21:38:56 +01:00
Bartosz Dziewoński
1fc2e3a3f1 Restore compatibility with overrides for IndexPager::makeLink()
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
2022-09-12 07:52:13 +02:00
Bartosz Dziewoński
cfd6ffe7bb Introduce PagerNavigationBuilder for making pagination links
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
2022-09-05 16:10:36 -04:00
Petr Pchelko
92564edc7c Use Message::page instead of Message::title
Also modified new APIs added to ApiErrorFormatter to
use PageReference instead of Title.

Change-Id: I093c89f8e1e6d383603f887358be6ece70f23a02
2021-06-09 13:18:22 +00:00
DannyS712
c6bd2f4c93 PrevNextNavigationRenderer: readability cleanup
Should be a no-op

Change-Id: I7c94dd923c4bc4478885dc02195a65c39bf0c16a
2020-11-22 14:03:15 +00:00
DannyS712
94169ee873 Whitespace cleanup: Use tabs for indentation, avoid double spaces
Change-Id: I346073b59d283029bd6666356c62c81e687ea5e6
2020-06-27 07:53:07 +00:00
Daimona Eaytoy
c659bc6308 Unsuppress another phan issue (part 7)
Bug: T231636
Depends-On: I2cd24e73726394e3200a570c45d5e86b6849bfa9
Depends-On: I4fa3e6aad872434ca397325ed7a83f94973661d0
Change-Id: Ie6233561de78457cae5e4e44e220feec2d1272d8
2019-09-03 17:19:21 +00:00
clarakosi
4ca72763ec Refactor buildPrevNextNavigation
Refactored buildPrevNextNavigation() into standalone helper class,
PrevNextNavigationRenderer, to be used by both SpecialPages and Pagers.

Bug:T207977
Change-Id: Ic49837a451f795ec203e867961ec1c69075cc91a
2019-06-05 19:32:27 -04:00