aboutsummaryrefslogtreecommitdiffstats
path: root/includes/api/ApiPageSet.php
Commit message (Collapse)AuthorAgeFilesLines
* api: Remove deprecated ApiPageSet::get*TitlesUmherirrender2025-03-261-67/+0
| | | | | | | | | | | | | The following functions were removed: - ApiPageSet::getTitles - ApiPageSet::getGoodTitles - ApiPageSet::getMissingTitles - ApiPageSet::getGoodAndMissingTitles - ApiPageSet::getRedirectTitles - ApiPageSet::getSpecialTitles Bug: T339384 Change-Id: Iba8499c2d1b4a10b918f563069534b90fed7f6f9
* Replace call_user_func with dynamic function callUmherirrender2025-02-131-2/+1
| | | | | | | | Use modern php syntax to call a callable. Reduce the stack trace to improve performance and better IDE and static analyzer support Change-Id: I9ef131032a662a3b8db69aa7079dbd51f88f575a
* Replace isset() with null check on variables or globalsUmherirrender2024-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: Ia53b71dff3299837856ae3c004cd0227bd45e05b
* Add namespace to includes/api classesJames D. Forrester2024-09-251-0/+7
| | | | | Bug: T353458 Change-Id: I3ea6b08c5018ba03ba45c5766e1f46e12f6b8597
* Fix specifying messages with params as arrays in API documentationBartosz Dziewoński2024-08-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Follow-up to 12a4c08ad83ef55e440b88e5f9d511fd224afa6f. I didn't review it carefully enough to notice that when these functions return arrays, they contain a message key and parameters, not a key and fallback keys (while other API documentation message code uses fallback keys). Instead of `$this->msg( $msg )`, this code must be written as `is_array( $msg ) ? $this->msg( ...$msg ) : $this->msg( $msg )` or `$this->msg( Message::newFromSpecifier( $msg ) )`, both of which are ugly, but the latter looks a bit better to me. Bonus changes: * Add documentation to prevent a repeat of this mistake in the future * Remove some unreachable dieDebug() calls (the Message class already throws for bad inputs) It seems that we don't have any definitions using such arrays in the core API classes. There are only a few uses in extensions, e.g. AbuseFilter's 'apihelp-query+abuselog-param-filter' message, which is passed the wrong parameter without this change. Bug: T372988 Change-Id: I44c1c3c7d0c069e500c85a58c27e9b675b0b68ee
* Move Language and friends into Language namespaceJames D. Forrester2024-08-101-0/+2
| | | | | Bug: T353458 Change-Id: Id3202c0c4f4a2043bf97b7caee081acab684155c
* api: Hard-deprecate ApiPageSet::get*TitlesUmherirrender2024-07-201-6/+12
| | | | | | | | | | | | | | The following functions are now hard-deprected: - ApiPageSet::getTitles - ApiPageSet::getGoodTitles - ApiPageSet::getMissingTitles - ApiPageSet::getGoodAndMissingTitles - ApiPageSet::getRedirectTitles - ApiPageSet::getSpecialTitles Bug: T339384 Depends-On: Ie117ac8417e7f62ef3f199312a7f57df205900b2 Change-Id: I9533f89bbd370bcec43ca37200b2fedd0610183f
* api: Fix incomplete docs for ApiPageSet::$mRequestedPageFieldsthiemowmde2024-07-071-7/+7
| | | | | | | | | | | | | | Unfortunately Phan gets super confused here, which is why I had to split this off from I454baef. While it might be possible to silence Phan I think the better solution is to get rid of the problematic null initialization. The null is never used for anything, anywhere. The contrary. In ApiPageSet::processDbRow() the null values are accessed with an array operator as if they are arrays, which (currently) forces PHP to silently initialize it to actually be an empty array. Instead I suggest to make this magic behavior explicitely visible. Change-Id: If7c4f49e46cc6050942611a7b2bca46ea550b31c
* api: Use much more specific PHPDoc type hints in ApiPageSetthiemowmde2024-07-071-30/+30
| | | | | | | | | | | A lot of arrays cleverly used as maps and sets in here. I believe it's very much worth documenting them all as precise as possible. This does have potential ripple effects on all code that uses these. Naturally this can't have an effect in production as it's exclusively about PHPDoc documentation. Change-Id: I454baef2d871cbbaf0bb85886774cf74728b692a
* api: Replace deprecated ApiPageSet::getGoodTitlesUmherirrender2024-07-061-5/+5
| | | | | Bug: T339384 Change-Id: Ib2872498338c01ad63bbcee859f89f94311ee325
* api: Use namespaced classesUmherirrender2024-06-141-0/+2
| | | | | | Changes to the use statements done automatically via script Change-Id: Icc5b59f9ef6319d1fb785fcda17f43c94f94cc38
* Use more fitting IReadableDatabase type in ApiPageSetthiemowmde2024-06-021-2/+2
| | | | | | | | | | | The parameter is unused anyway. If we are ever going to reuse this parameter for anything it clearly needs to be a IReadableDatabase, IMHO. It probably makes sense to deprecate and remove the method entirely. But I want to start simple. Just to unblock I270a8e8. Change-Id: I9ce8740dc5452d2502442e5fe733ff7ded56d804
* Namespace includes/cacheJames D. Forrester2024-02-201-0/+3
| | | | | Bug: T353458 Change-Id: Ic3f3168ef17113f5fb3ec11e0a47f52d65eefba9
* More specific array type hints in ApiPageSetthiemowmde2024-01-081-3/+3
| | | | | | | | While this is technically the same as before, the array<int,…> syntax makes it more obvious that the array index is a meaningful value (e.g. a page id) and not just a meaningless sequence. Change-Id: Idc49d6f7cf43b158632115dc1b76c0cab548bc56
* Remove allowances for nullable `rd_interwiki` and `rd_fragment`Bartosz Dziewoński2023-10-031-2/+2
| | | | | | | | | After the other changes in T346290 these fields can never be null. The only place that needs to handle null values is the migration script fixInconsistentRedirects.php. Bug: T346290 Change-Id: I0235c4be93b203f369b29522b54c0110ee8d61e9
* Merge "WikiPage: Stop trying to insert `redirect` rows on reads"jenkins-bot2023-09-221-25/+0
|\
| * WikiPage: Stop trying to insert `redirect` rows on readsBartosz Dziewoński2023-09-151-25/+0
| | | | | | | | | | | | | | | | This migration has been completed to the extent possible (except for corrupted pages), and we can remove this to simplify the code. Bug: T346290 Change-Id: I3627b3d364c4faf836bbe176cb8709f469113bac
* | Namespace remaining Title-related classes under \MediaWiki\TitleJames D. Forrester2023-09-191-0/+1
| | | | | | | | | | Bug: T166010 Change-Id: Ia2e5a7367cc8cdbd8a7b845ae2fd5d776ff22891
* | Namespace NamespaceInfo under \MediaWiki\TitleJames D. Forrester2023-09-191-0/+1
| | | | | | | | | | | | | | One of the big ones, so doing this alone. Bug: T166010 Change-Id: Ibe103cd362535d3cb94cb8931e95fc74099d1497
* | Namespace remaining 'specialpage' files under \MediaWiki\SpecialPageJames D. Forrester2023-09-181-0/+1
|/ | | | | | | SpecialPageFactory is already here, but none of the others were yet. Bug: T166010 Change-Id: I9689bf0a1ab329625e23669b99f019b96295fffd
* Bump phan to 0.13.0Amir Sarabadani2023-09-111-6/+6
| | | | Change-Id: I57c25d953700ca1cd97cc71ec2a28cbeb9ee875f
* Use real type hints for services etc. in api/ except ApiQuery*.phpBartosz Dziewoński2023-08-291-26/+9
| | | | | | | | | | | | | | | Mostly used find-and-replace: Find: /\*[\*\s]+@var (I?[A-Z](\w+)(?:Interface)?)[\s\*]+/\s*(private|protected|public) (\$[a-z]\w+;\n)((?=\s*/\*[\*\s]+@var (I?[A-Z](\w+)(?:Interface)?))\n|) Replace with: \3 \1 \4 Followed by some manual review to make sure I'm not changing too much, omitting some changes that looked too complicated and anything that caused test failures, and some whitespace fixes. Change-Id: I6ec7587607df4f1a4f448a096c3e44c4e5270b70
* Replace array_keys in foreach to use $_ as value insteadUmherirrender2023-07-101-1/+1
| | | | | | | | When the value of the associated array is not used, there is no need to use array_keys and create internal a copy of the array, just omit the value with $_ to tell static analyzer that the var is unused. Change-Id: I5c6d667e98c0167c0573c683f0d617bc1d4ca619
* api: Switch to use IConnectionProviderAmir Sarabadani2023-04-241-1/+1
| | | | | | | As much as possible Bug: T330641 Change-Id: Icb943d6d65b210760ba8966419327c9603e768e0
* Fix Phan suppressions related to Title::castFrom*() and friendsBartosz Dziewoński2023-04-221-4/+2
| | | | | | | | | | | | | | | | | | | | | 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
* Fix infinite loop for self-redirects with variants conversionxiplus2023-03-251-1/+3
| | | | | | | | | | The redirect targets another variant, but the target does not exist. It causes infinite loop when querying the page with the redirect and converttitles flags are both set. Check the mConvertTitles to stop re-resolving the same title. Bug: T333050 Change-Id: I64c5886dbd0a9148eeff033ba56306bcb7f2eb8c
* Reorg: Namespace the Title classJames D. Forrester2023-03-021-0/+1
| | | | | | | | | | | | | | | | | | | 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 Title-related classes to title/Amir Sarabadani2022-11-261-0/+1
| | | | | | | | | | | | | | These three classes: - TitleArray - TitleArrayFromResult - TitleFactory We need to move these and the rest of files under title/ to Title/ (and namespace them) but the patch will become way too big given that Title class is also one of them. Bug: T321882 Change-Id: Iac1688172ee457348a08a470c86e047571feb8e0
* Reorg: Move some of request related classes to MediaWiki/RequestAmir Sarabadani2022-10-281-0/+1
| | | | | | | | | | | | | | | Redoing I5ea70120d74 but without moving WebRequest that caused issues with phan-taint-plugin. Moving: - DerivativeRequest - FauxRequest - FauxRequestUpload - PathRouter - WebRequestUpload Bug: T321882 Change-Id: I832b133aaf61ee9f6190b0227d2f3de99bd1717b
* Revert "Reorg: Move some of request related classes to MediaWiki/Request"Zabe2022-10-271-1/+0
| | | | | | | | | This reverts commit 2bdc0b2b7209441a42a784157633a8a01b321922. Reason for revert: T166010#8349431 Bug: T166010 Change-Id: Idcd3025647aec99532f5d69b9c1718c531761283
* Reorg: Move some of request related classes to MediaWiki/RequestAmir Sarabadani2022-10-261-0/+1
| | | | | | | | | | | | | Moving: - DerivativeRequest - FauxRequest - FauxRequestUpload - PathRouter - WebRequest - WebRequestUpload Bug: T166010 Change-Id: I5ea70120d745f2876ae31d039f3f8a51e49e9ad8
* Use short array destructuring instead of list()Tim Starling2022-10-211-1/+1
| | | | | | | | Introduced in PHP 7.1. Because it's shorter and looks nice. I used regex replacement. Change-Id: I0555e199d126cd44501f859cb4589f8bd49694da
* api: Minor code cleanupReedy2022-08-141-1/+1
| | | | Change-Id: I1f20597093448d00435158a9ac861873000bb057
* api: Migrate IDatabase::select() to SelectQueryBuilder interfaceDerick Alangi2022-08-081-23/+40
| | | | | Bug: T311866 Change-Id: I5d79fce9d48b0d366ee2a918d3133186a5b65eb7
* api: Replace numerous more deprecated constantsReedy2022-06-061-2/+3
| | | | Change-Id: I498a315b8b4b56d5e2f939e797adbe0487cd7d07
* api: Replace numerous deprecated constantsReedy2022-06-061-9/+9
| | | | Change-Id: I34ffcb70efbfa257da8dab6e0790aa0d697caf5b
* Use MainConfigNames instead of string literals, #2Aryeh Gregor2022-04-131-1/+2
| | | | | | | This covers all occurrences of /onfig->.*get( '/ in includes/. Undoubtedly there are still plenty more to go. Change-Id: I33196c4153437778496f40436bcde399638ac361
* phan: Disable null_casts_as_any_type settingUmherirrender2022-03-211-0/+4
| | | | | | | | | | | Make phan stricter about null types by setting null_casts_as_any_type to false (the default in mediawiki-phan-config) Remaining false positive issues are suppressed. The suppression and the setting change can only be done together Bug: T242536 Bug: T301991 Change-Id: I0f295382b96fb3be8037a01c10487d9d591e7e01
* api: Get all services for ApiPageSet in constructorUmherirrender2022-03-151-37/+65
| | | | | | | build: Removes phan suppresses due to changed parse order of phan-taint Bug: T283314 Change-Id: I616d1f8f62225210566d0ea5b9cc295fdc3e54fb
* api: Fix documenation/types related to null and int typesUmherirrender2022-02-241-1/+1
| | | | | | Found by phan strict checks Change-Id: I2b2ae12ca39d67140f0f3c1cc5066c8ef72716de
* ApiPageSet: Add "missing": true to missing revisionsLucas Werkmeister2022-02-051-1/+2
| | | | | | | | This makes them consistent with missing titles and page IDs in ApiQuery::outputGeneralPageInfo(). Bug: T301041 Change-Id: Ic2be91dce592521682dc7933161cd23fb00e628e
* Remove some more comments that literally repeat the codeThiemo Kreuz2021-12-091-2/+2
| | | | | | | | Nothing to learn from these. You can find a longer explanation in the comments in I93751e6. Change-Id: I195aae70fc282b58be5b18160783f27d38605d15
* Add missing null to string casts when using rd_fragment and suchThiemo Kreuz2021-11-021-2/+2
| | | | | | | | These columns are nullable, but the method doesn't accept null. Found in Logstash. Change-Id: I3eaafe31005c9319fdd03f8f4b54e7b51ef430f9
* api: Do not use isset() to check for null on local var in ApiPageSetUmherirrender2021-08-281-2/+2
| | | | | | local vars always defined, no need to use isset Change-Id: Id033d2eb9a878e9f5bb00ee90687e36511cd2ef8
* Use array_fill_keys() instead of array_flip() if that reflects the ↵Tim Starling2021-06-151-3/+3
| | | | | | | | | | | | | | | | | | developer's intention array_fill_keys() was introduced in PHP 5.2.0 and works like array_flip() except that it does only one thing (copying keys) instead of two things (copying keys and values). That makes it faster and more obvious. When array_flip() calls were paired, I left them as is, because that pattern is too cute. I couldn't kill something so cute. Sometimes it was hard to figure out whether the values in array_flip() result were used. That's the point of this change. If you use array_fill_keys(), the intention is obvious. Change-Id: If8d340a8bc816a15afec37e64f00106ae45e10ed
* ApiPageSet: update reference to Language::findVariantLink()DannyS7122021-05-221-2/+2
| | | | | | Method was removed, uses ILanguageConverter::findVariantLink() Change-Id: Ib2d3bc67b731582e4f83c69d95cca2ed97773662
* ApiPageSet: add documentation to all variablesDannyS7122021-05-151-11/+71
| | | | | | | Starting a larger patch to cleanup and refactor the class, and it helps to have everything documented. Change-Id: I089a8f6bb89742d594388abe49bc47cd132113f6
* Merge "Remove unused default values from class properties"jenkins-bot2021-05-131-2/+2
|\
| * Remove unused default values from class propertiesThiemo Kreuz2021-05-121-2/+2
| | | | | | | | | | | | | | | | In all these cases the property is unconditionally set in the constructor. The extra initialisation is effectively dead code and an extra source of errors and confusion. Change-Id: Icae13390d5ca5c14e2754f3be4eb956dd7f54ac4
* | ApiPageSet: replace Title in method signaturesdaniel2021-05-121-13/+93
|/ | | | | Bug: T278459 Change-Id: Ie817fd476d6236791431b5ba5ce557800ef5222d