aboutsummaryrefslogtreecommitdiffstats
path: root/includes/api/ApiBase.php
Commit message (Collapse)AuthorAgeFilesLines
* Merge "api: Switch to use IConnectionProvider"jenkins-bot2023-05-021-3/+4
|\
| * api: Switch to use IConnectionProviderAmir Sarabadani2023-04-241-3/+4
| | | | | | | | | | | | | | As much as possible Bug: T330641 Change-Id: Icb943d6d65b210760ba8966419327c9603e768e0
* | ApiBase: Remove special error messages for blocksBartosz Dziewoński2023-04-261-34/+36
|/ | | | | | | | | | | Various tools want to display the full HTML error messages when &errorformat=html&errorsuselocal=1 is specified. Depends-On: I06c89534be605557ee9b0d90d2748f806fa2ae9e Depends-On: I353e34d81afaa06750f8725181c808fabcebea42 Depends-On: Ib60ac795e9dda124b927816321aafe0853ee4500 Bug: T335319 Change-Id: Ie17987991d1e9a0d77da97e3a81fe0a21c6d7866
* Fix Phan suppressions related to Title::castFrom*() and friendsBartosz Dziewoński2023-04-221-3/+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
* 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
* API: Allow use of multivalue parameter documentation for templatesGergő Tisza2023-01-171-7/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | Allow the use of PARAM_HELP_MSG_PER_VALUE for PARAM_TYPE='string' and PARAM_ISMULTI=true, which is the setting used for templated parameters (PARAM_TEMPLATE_VARS). It's common for templated parameters to take the variable parts of the name from some fixed set, but they are required to use PARAM_TYPE=string so it makes sense to allow the use of multi- valued parameter documentation for that case. The other option would have been to allow templated parameters to be enums, which also makes sense and could be a complimentary improvement; there are two reasons to prefer the current approach: * Getting the list of allowed values might have a performance impact that we only want to incur when the (optional) parameter is used, while an enum requires the value list to be generated every time the API module is used. So there would be some value in using string type for templated parameters with a known set of documentable values even if enum were also allowed. * Per-value documentation might be useful outside the template use case for non-restricted multi-valued strings: maybe all values are allowed but there are some values with special meanings that are worth documenting. Change-Id: I53f9ae840c0a7eee76c4b57f95390b5045707efd
* Reorg: Move RawMessage to under language/Amir Sarabadani2022-12-161-0/+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
* Make use of ?:, ?? and ??= operators in mostly trivial casesthiemowmde2022-12-051-3/+1
| | | | | | | | | | The motivation is to make the code less confusing. I hope this is the case. ?? is an older PHP 7.0 feature. ??= was added in PHP 7.4, which we can finally use. Change-Id: Id807affa52bd1151a74c064623b41d950a389560
* api: Validate timestamp in continue parameterUmherirrender2022-11-011-2/+11
| | | | | Bug: T321265 Change-Id: Ib46bc3e643938f56e0c58a3c5f5e093327e00964
* Use short array destructuring instead of list()Tim Starling2022-10-211-4/+4
| | | | | | | | Introduced in PHP 7.1. Because it's shorter and looks nice. I used regex replacement. Change-Id: I0555e199d126cd44501f859cb4589f8bd49694da
* build: Update mediawiki/mediawiki-phan-config to 0.12.0Daimona Eaytoy2022-10-081-3/+0
| | | | | | | | This patch only adds and removes suppressions, which must be done in the same patch as the version bump. Bug: T298571 Change-Id: I4044d4d9ce82b3dae7ba0af85bf04f22cb1dd347
* Fixes for the phan upgrade, part 1Daimona Eaytoy2022-10-081-0/+1
| | | | | | | | | | | | | Mainly, document some parameters as non-empty-array so that phan knows the list of arguments won't be empty when unpacking. In EditPage, account for hooks potentially unsetting the copyright notice. Also rewrite some code in LogPager, so it's hopefully easier for phan to understand what's going on. Change-Id: Ic0638571554424098d0743db32dd46723a08e103
* Deduplicate code for parsing API 'continue' parametersBartosz Dziewoński2022-09-291-0/+31
| | | | | | | | | | | | | | 30+ API modules had nearly identical code to split and validate the value of the 'continue' parameter. Introduce the ApiBase::parseContinueParamOrDie() method and use it to replace most usages of ApiBase::dieContinueUsageIf(). A few remain in modules with more complex continuation handling. Inline most single-use variables that remained after validation was moved into the new method. Change-Id: I66bd59ecd4ad16e2039e90f7d66cfa276e6c1c2a
* api: Minor code cleanupReedy2022-08-141-10/+4
| | | | Change-Id: I1f20597093448d00435158a9ac861873000bb057
* Make use of ?? and ?: operators where it makes senseThiemo Kreuz2022-08-041-10/+2
| | | | Change-Id: I1d9d62d80b17d1a05222c6e82f631cb801c311a8
* Pass int to ApiUsageException::newWithMessage()'s $httpCode paramMark A. Hershberger2022-06-291-2/+2
| | | | | Bug: T311544 Change-Id: I4fd4557dbac889175eef4582fa57f6f2274f3a69
* api: Replace deprecated WikiPage::factory/newFromIDUmherirrender2022-06-241-2/+2
| | | | | Bug: T297688 Change-Id: I5537bd615484bf3a9eb5b597121fa4881c1a5961
* Replace deprecated wfReadOnly/wfReadOnlyReasonUmherirrender2022-06-201-1/+1
| | | | | Bug: T283978 Change-Id: I49f8c7bf1162dc834a1708e2e581f6fb264bbd0a
* ApiBase: Reset self::$filterIDsCache between testsdaniel2022-06-131-0/+12
| | | | | | | | | self::$filterIDsCache caches database state, it gets out of whack when we reset the database between test cases. The cache was originally introduced to fix T140302. Change-Id: I9a05c60d84d92f6798154bfa77c6288576dc53bc
* api: Replace numerous more deprecated constantsReedy2022-06-061-10/+10
| | | | Change-Id: I498a315b8b4b56d5e2f939e797adbe0487cd7d07
* api: Replace numerous deprecated constantsReedy2022-06-061-1/+1
| | | | Change-Id: I34ffcb70efbfa257da8dab6e0790aa0d697caf5b
* Use MainConfigNames instead of string literals, #2Aryeh Gregor2022-04-131-4/+6
| | | | | | | This covers all occurrences of /onfig->.*get( '/ in includes/. Undoubtedly there are still plenty more to go. Change-Id: I33196c4153437778496f40436bcde399638ac361
* phan: Remove PhanTypePossiblyInvalidDimOffset suppressionUmherirrender2022-03-281-0/+1
| | | | | | | | | | | Make phan stricter about array keys Remaining false positive issues are suppressed. The suppression and the setting change can only be done together Bug: T304887 Depends-On: I3105a5fd4826f8667b5232834defc5ec93be32a1 Depends-On: Ie9610a6e83731468311edb3ed17f80fc509de385 Change-Id: I701f12ab94478c3b8e7fd82110ade74a8e6b04ef
* Use UserRigorOptions directlyTim Starling2022-03-251-2/+2
| | | | | | | Conventionally, public constants are accessed via their declaring class, except for self:: which is an acceptable shortcut. Change-Id: If05eab72140267e6ef54736710d751d7f24a7860
* phan: Disable null_casts_as_any_type settingUmherirrender2022-03-211-0/+9
| | | | | | | | | | | 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
* Define MW_INSTALL_PATH constant and BaseDirectory config.daniel2022-03-041-4/+3
| | | | | | | | | | | Application logic should use the BaseDirectory config variable. Framework code should use MW_INSTALL_PATH to locate files should. NOTE: Update https://www.mediawiki.org/wiki/Manual:$IP Bug: T300301 Depends-On: I7142af16d692f26e90673b058029f572c1ea3991 Change-Id: Ib4caa80bb7007c4c7960a2fd370cf5da7d9ba344
* ApiBase: Annotate deprecated constants individuallyReedy2021-10-091-1/+58
| | | | Change-Id: I30f2e21eb5d10a54fa5955586be14d9c3eddf056
* API: Fix null docs in ApiBaseUmherirrender2021-09-211-2/+2
| | | | Change-Id: I63399b1ee2f2c8d6f7f6a5781a5a61de5d21ede8
* API: Using @return never documentation on more functionsUmherirrender2021-09-111-0/+6
| | | | | | | Due to a bug in phan the usage needs suppression Bug: T240141 Change-Id: Ic2da20b663ff2ff291c73329ac1f152d61d1df56
* Using @return never documentation on always-throw-functionUmherirrender2021-09-071-0/+3
| | | | | | | | | | This helps phan to detect unreachable code and also impossible types after the functions. It helps phan to avoid false positives for array keys when the keys are checked before Bug: T240141 Change-Id: I895f70e82b3053a46cd44135b15437e6f82a07b2
* Revert "Use CsrfTokenSet as CSRF token source"Kunal Mehta2021-08-051-1/+5
| | | | | | | This reverts commit 0d75fdb4f73ddbf4ad5f29e14258d58e507d55b4. Bug: T287542 Change-Id: Iedd3461869f973f8d621a39e6ad4674cbb577551
* Use CsrfTokenSet as CSRF token sourcePetr Pchelko2021-07-121-5/+1
| | | | Change-Id: I079d2c802d9b48d6abf7f37fa9ef7dafac631345
* api: Inject GroupPermissionsLookup into modulesUmherirrender2021-07-061-12/+0
| | | | | | | Remove the @internal getter for the global and use MediaWikiServices directly at one remaining place. Change-Id: I120f9c00d22d6dcf2a996eec5b9d5e5d41b68284
* Merge "Authority: expose user block info"jenkins-bot2021-06-301-14/+20
|\
| * Authority: expose user block infodaniel2021-06-301-14/+20
| | | | | | | | | | | | | | | | | | Expose info about user blocks from Authority. This allows calling code to provide more detailed information to the user about why they are denied some action on the wiki. Bug: T271494 Change-Id: Ia84e469888866d72752aad355292666c31e12bad
* | api: Replace deprecated User::newFromName/getOption in ApiBaseUmherirrender2021-06-281-5/+7
|/ | | | Change-Id: Idfb429549f0281e2edbc532efc347e83e77ab80c
* Replace uses of DB_MASTER with DB_PRIMARY in documentation and local variablesJames D. Forrester2021-05-141-3/+3
| | | | | | | This is just a start. Bug: T254646 Change-Id: I9213aad4660e27afe7ff9e5d2e730cbf03911068
* Merge "Remove hard deprecated methods from ApiBase"jenkins-bot2021-05-101-161/+0
|\
| * Remove hard deprecated methods from ApiBaseDannyS7122021-05-091-161/+0
| | | | | | | | | | | | | | | | | | * ::explodeMultiValue * ::parseMultiValue * ::validateLimit * ::validateTimestamp Change-Id: I326abedc01d7096e67e193c7967b107e253b8916
* | ApiBase: deduplicate logic to avoid infinite loops for ApiMain methodsDannyS7122021-05-091-25/+23
|/ | | | | | Add private helper ApiBase::dieIfMain() Change-Id: I3d9881356bd66447e67ccccf20697f4b88885854
* Use Authority and GroupPermissionLookup in Action APICindy Cicalese2021-02-231-20/+37
| | | | | | | | | | | | | | | | | | | Replaces calls directly to PermissionManager with calls to the Authority object available from Context or the GroupPermissionLookup service. This patch does not address use of PermissionManager for blocks. Deprecations: - ApiBase::checkUserRightsAny deprecated passing optional User parameter - ApiBase::checkTitleUserPermissions deprecated passing LinkTarget as first parameter, takes PageIdentity instead Bug: T271462 Bug: T271854 Change-Id: I5d7cac1c28a37e074750c46cda03283980a07fca
* Use static closures where safe to useUmherirrender2021-02-111-2/+2
| | | | | | | | | This is micro-optimization of closure code to avoid binding the closure to $this where it is not needed. Created by I25a17fb22b6b669e817317a0f45051ae9c608208 Change-Id: I0ffc6200f6c6693d78a3151cb8cea7dce7c21653
* Merge "api: Add new 'raw' parameter type which avoids Unicode NFC normalization"jenkins-bot2021-01-011-0/+1
|\
| * api: Add new 'raw' parameter type which avoids Unicode NFC normalizationC. Scott Ananian2020-12-231-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The mandatory Unicode NFC normalization on API parameters was causing spurious dirty diffs in VisualEditor/DiscussionTools when editors used HTML entities to encode non-NFC codepoints, like  . Although wikitext is (ought to be!) in NFC form, the output HTML may not be, due to explicit entities in the wikitext. This type is used in VisualEditor change I0d34c9a01f1132c2616ed3392ea40d8b73e15325 to prevent Parsoid HTML from being corrupted when it is round-tripped. Bug: T266140 Change-Id: I2e78e660ba1867744e34eda7d00ea527ec016b71
* | Improve custom folding and groupingTim Starling2020-12-231-47/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | PHPStorm can use custom folding regions defined in either the VisualStudio style or the NetBeans style. The VisualStudio style is more pleasing to the eye and also works as a vim foldmarker. So get rid of the previous vim foldmarkers, and use region/endregion. region/endregion need to be in a single-line comment which is not a doc comment, and the rest of the comment is used as a region heading (by both PHPStorm and vim). So to retain Doxygen @name tags, it is necessary to repeat the section heading, once in a @name and once in a region. Establish a standard style for this, with a divider and three spaces before the heading, to better set off the heading name in plain text. Besides being the previous vim foldmarker, @{ is also a Doxygen grouping command. However, almost all prior usages of @{ ... @} in this sense were broken for one reason or another. It's necessary for the @{ to be in a doc comment, and DISTRIBUTE_GROUP_DOC doesn't work if any of the individual members in the group are separately documented. @name alone is sufficient to create a Doxygen section when the sections are adjacent, but if there is ungrouped content after the section, it is necessary to use @{ ... @} to avoid having the Doxygen group run on. So I retained, fixed or added @{ ... @} in certain cases. I wasn't able to test the changes to the trait documentation in Doxygen since trait syntax is not recognised and the output is badly broken. Change-Id: I7d819fdb376c861f40bfc01aed74cd3706141b20
* | Swap out uses of User->isLoggedIn() with ->isRegistered()James D. Forrester2020-12-221-1/+1
| | | | | | | | | | Bug: T270450 Change-Id: I90ff94a553ebae9a4ef97c25c333f067f19c327d
* | ApiBase: update outdated comment about canApiHighLimitsDannyS7122020-12-141-1/+1
|/ | | | | | | | No longer unstubs $wgUser, because the fallback in ::getUser is creating a user from the current session Bug: T243708 Change-Id: I06d78b3c9ec81c558b56550a934af2db045685d9
* build: Updating mediawiki/mediawiki-phan-config to 0.10.5Umherirrender2020-12-121-1/+1
| | | | Change-Id: I343d2bae626a3903eb1e67c05bf5caef4314b7dd
* Improve docs in api related classesUmherirrender2020-11-131-5/+5
| | | | Change-Id: I78338d48530f098fa5d36fe84cfd45c0d160f444
* Merge "Update a lot of unspecific "array" types in PHPDocs"jenkins-bot2020-11-131-1/+1
|\