aboutsummaryrefslogtreecommitdiffstats
path: root/includes/Navigation
Commit message (Collapse)AuthorAgeFilesLines
* Remove trivial 1-line PHPDocs that just repeat the codethiemowmde2025-01-161-3/+0
| | | | | | | | | | | | | I assume these are all either auto-generated by an IDE or the language-level type declarations have been added later. In any case the comments don't add any new information to what the code already says. This is just extra clutter that makes the code harder to read, I would argue. There are many, many more comments like this. In this patch I intentionally focus on the most trivial 1-line comments. Change-Id: Ia294bf4ce0d8a77036842fe25884bc175c2b0e7d
* Replace isset() with falsy checksUmherirrender2024-12-191-3/+3
| | | | | | | | | isset() should only be used to suppress errors, not for null check. When the property is always defined, there is no need to use isset. Found by a new phan plugin (2efea9f989) https://www.mediawiki.org/wiki/Manual:Coding_conventions/PHP#isset Change-Id: I186e799256fbaf5ee77558bd146f9418dd5eaacc
* Merge "Add type hints to detect bool/null message params"jenkins-bot2024-11-141-2/+7
|\
| * Add type hints to detect bool/null message paramsBartosz Dziewoński2024-11-141-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | Add more precise type hints to every method I could find that takes message params as arguments, so that Phan will warn if bool or null is passed, which is deprecated (T378876). Errors found in this repository thanks to these checks are fixed in I286a4a51e879bdf61f65c87dc078621c51045bee. Bug: T378876 Change-Id: I3e0df790ff9db2fa630f82408a7254a359fe61ca
* | Navigation: allow integers in PagerNavigationBuilder queriesDaimona Eaytoy2024-10-011-10/+10
|/ | | | | | | | | | The existing `?string` typehint causes phan to complain when integers are passed. However, these values are only used to build a query string, and the code works just as fine with integers. On top of that, some of these things are commonly integers anyway (things like limits and offsets), so it makes sense to accept integers explicitly. Change-Id: I5c6b8ad8075d295666a6a04d8c95398dfd9f4060
* Namespace Message, move to appropriate directoryJames D. Forrester2024-02-141-1/+1
| | | | | Bug: T353458 Change-Id: I088cbc53fbcdb974e5b05b45a62e91709dacc024
* Fix Phan suppressions related to Title::castFrom*() and friendsBartosz Dziewoński2023-04-221-1/+1
| | | | | | | | | | | | | | | | | | | | | 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
* Remove deprecated pager methods/classesBartosz Dziewoński2023-03-222-106/+0
| | | | | | | | | | | Deprecated in MW 1.39: * Ic75bd597b210e14612ca3aebb531b659897e8294 * I4e2f36b543462aa5d852733da650fb70d49ebf06 Hard-deprecated in MW 1.40: * I09e9203b19e3808af9348db8a889d5e118282230 Change-Id: I17bd8f80e87a04674e826d7966aa3ddb011fc7ba
* Hard-deprecate deprecated pager methods/classesBartosz Dziewoński2023-03-152-0/+2
| | | | | | | | | | Deprecated in MW 1.39 in commits: * Ic75bd597b210e14612ca3aebb531b659897e8294 * I4e2f36b543462aa5d852733da650fb70d49ebf06 Depends-On: I8b3adfe907ae16279ec3d480b7eedec5901884f2 Depends-On: I376361bc86a6085fe94a5439b04239ab123a515c Change-Id: I09e9203b19e3808af9348db8a889d5e118282230
* Reorg: Namespace the Title classJames D. Forrester2023-03-022-2/+2
| | | | | | | | | | | | | | | | | | | 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
* Reorg: Move HTML-related classes out of includes/ to Html/Amir Sarabadani2023-02-161-1/+1
| | | | | Bug: T321882 Change-Id: I5dc1f7e9c303cd3f5b9dd7010d6bb470d8400a18
* Reorg: Move RawMessage to under language/Amir Sarabadani2022-12-161-1/+1
| | | | | | | | | | 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
* PagerNavigationBuilder: Document that nulls in setLinkQuery() etc. are allowedBartosz Dziewoński2022-11-021-10/+10
| | | | | | | 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
* pager: Remove unused PagerNavigationBuilder::setExtra()Bartosz Dziewoński2022-11-021-15/+0
| | | | | | | | | | 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
* Restore compatibility with overrides for IndexPager::makeLink()Bartosz Dziewoński2022-09-121-3/+25
| | | | | | | | | | | | | | | | | | | 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: cfd6ffe7bbadf8177da34460930ca4780bd38524 Bug: T317477 Change-Id: I4e2f36b543462aa5d852733da650fb70d49ebf06
* Introduce PagerNavigationBuilder for making pagination linksBartosz Dziewoński2022-09-052-97/+379
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Use Message::page instead of Message::titlePetr Pchelko2021-06-091-4/+4
| | | | | | | Also modified new APIs added to ApiErrorFormatter to use PageReference instead of Title. Change-Id: I093c89f8e1e6d383603f887358be6ece70f23a02
* PrevNextNavigationRenderer: readability cleanupDannyS7122020-11-221-16/+53
| | | | | | Should be a no-op Change-Id: I7c94dd923c4bc4478885dc02195a65c39bf0c16a
* Whitespace cleanup: Use tabs for indentation, avoid double spacesDannyS7122020-06-271-2/+8
| | | | Change-Id: I346073b59d283029bd6666356c62c81e687ea5e6
* Unsuppress another phan issue (part 7)Daimona Eaytoy2019-09-031-7/+17
| | | | | | | Bug: T231636 Depends-On: I2cd24e73726394e3200a570c45d5e86b6849bfa9 Depends-On: I4fa3e6aad872434ca397325ed7a83f94973661d0 Change-Id: Ie6233561de78457cae5e4e44e220feec2d1272d8
* Refactor buildPrevNextNavigationclarakosi2019-06-051-0/+111
Refactored buildPrevNextNavigation() into standalone helper class, PrevNextNavigationRenderer, to be used by both SpecialPages and Pagers. Bug:T207977 Change-Id: Ic49837a451f795ec203e867961ec1c69075cc91a