aboutsummaryrefslogtreecommitdiffstats
path: root/includes/api/Validator
Commit message (Collapse)AuthorAgeFilesLines
* Use updated ObjectFactory namespaceAlexander Vorwerk2022-03-091-1/+1
| | | | | | | Depends-On: I99c5e5664d2401c36a9890f148eba7c25e6e8324 Depends-On: I48ab818b2965da14af15ef370aa83ad9455badd9 Depends-On: I018371e4b77911e56152ca7b2df734afc73f58a5 Change-Id: I04ebdb52102f6191d49a9cc70b1f98308299e72f
* Fix typos in comments (A-B)Siddharth VP2021-12-261-1/+1
| | | | Change-Id: I852453fbeeebdc4e34c0b35c0fdca4b4ab74fde9
* Remove deprecated ApiBase::PARAM_VALUE_LINKSReedy2021-10-091-5/+0
| | | | Change-Id: I1c544ef58ebb2c83ebdcf7284a8dad2ed364c608
* UserDef: use TitleParser instead of Title objectsDannyS7122021-09-141-1/+1
| | | | | | | | | | Migrate away from the Title object, use TitleParser::parseTitle() which returns a TitleValue which is enough. Will be followed by switching UserDefTest to a unit test, but in a separate commit. Change-Id: Ia756964861c4e0f3edea89f6beec2643243ca741
* UserDef: no need to return full User objectsDannyS7122021-09-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Maintain the existing behavior for creating based on a user id or name that does not correspond to an existing user: * if creating a User object based on the id 0, User::loadFromId() will load the defaults with the name being set to false, and User::getName() will convert that false to the ip of the current request. We probably don't want UserDef to be doing that, but this behavior should be changed separately - at the moment we are just matching the existing behavior (see the prior commit which adds tests to confirm the behavior isn't changing) * if creating a User object based on an id that cannot be found in the database, User::loadFromDatabase() will load the same defaults, *except* that it will set the user name to "Unknown user" * if creating a User object based on a name, User::getId() will, if the id isn't already known, return 0 if the name matches UserNameUtils::isIP() or ExternalUserNames::isExternal(). However, the User object is currently only created based on a name after passing an ExternalUserNames check, and the creation with RIGOR_VALID prevents it from being an ip. Thus, the existing code will call User::load(), which will check the database or fallback to 0 if the user does not exist. When creating a User from an id that does not exist, User::getId() will return that id, until after the object tries to fully load, after which it'll return 0 for the id. Since we cannot replicate this with UserIdentity (switching the id to 0 only after getName() is called for the first time) we set the id to always be 0, which is more accurate. This is the only change in behavior. We will remove the use of the context ip in a follow-up that will switch to using "Unknown user" instead. Accordingly, we will use a UserIdentityLookup as well as manual construction of UserIdentityValue objects to match this behavior. Bug: T288311 Change-Id: Ida80c5d04d721fafa8d66f656dbd346c6cf643eb
* Using @return never documentation on always-throw-functionUmherirrender2021-09-071-0/+1
| | | | | | | | | | 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
* Cleanup mixed space/tab line indentUmherirrender2021-09-041-2/+2
| | | | Change-Id: I833052a656b1ce419c0929f6f0514f2a33c2c4cc
* build: Updating dependencieslibraryupgrader2021-07-222-10/+10
| | | | | | | | | | | | | | composer: * mediawiki/mediawiki-codesniffer: 36.0.0 → 37.0.0 The following sniffs now pass and were enabled: * Generic.ControlStructures.InlineControlStructure * MediaWiki.PHPUnit.AssertCount.NotUsed npm: * svgo: 2.3.0 → 2.3.1 * https://npmjs.com/advisories/1754 (CVE-2021-33587) Change-Id: I2a9bbee2fecbf7259876d335f565ece4b3622426
* Use static closures where safe to useUmherirrender2021-02-111-1/+1
| | | | | | | | | 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-012-0/+7
|\
| * api: Add new 'raw' parameter type which avoids Unicode NFC normalizationC. Scott Ananian2020-12-232-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Remove unneeded return type hint from function in ApiParamValidatorUmherirrender2020-12-181-1/+1
|/ | | | | | Always throws an exception Change-Id: I2c95109a956e23425767b98bc35ae61b9df82e04
* Add API validator for titlesGergő Tisza2020-11-061-0/+5
| | | | | | The ISMULTI logic is copied from UserDef. Change-Id: I794e2277c462b86cb5c3888d1ba509b11fad62aa
* UserDef DINikki Nikkhoui2020-08-051-1/+4
| | | | | | | | | | | - Begin injecting services into UserDef to support unit tests. - Replace static User class functions with UserFactory functions. Bug: T259145 Bug: T257464 Change-Id: Iccc0c39e013679f15f2e62738c56df09ba56c494
* Add expiry type to ParamValidatorMusikAnimal2020-04-081-0/+2
| | | | | | | | | | | | | | | This commit also changes ApiWatch to make use of the new parameter type. Other APIs will be updated to use it in a separate patch (T248196). In doing this, we are for the first using logic within a TypeDef outside the API. This seems acceptable given TypeDefs chiefly appear to serve as a validation method, with otherwise no particular logic tied to the concept of APIs. wfIsInfinity() now uses ExpiryDef::INFINITY_VALS Bug: T248508 Change-Id: If8f0df059eafb73ec9f39cc076b3a9ce2412d60a
* Fix some PHPStorm inspection warnings in includes/apiTim Starling2020-02-182-0/+2
| | | | | | | | | | Notably: * In ApiManageTags, I used a switch instead of a dynamic function name, so that the call graph will be correct. * In ApiImageRotate, checkTitleUserPermissions() has always returned void, this was an error introduced in 4e6810e4a2c1d821d8d108c Change-Id: Iea22616b8e7e2e0cc804619a54f8690898b2cb82
* Move some validation logic from ApiStructureTest to ParamValidatorBrad Jorsch2020-02-042-13/+233
| | | | | | | | | | ApiStructureTest has a lot of logic for validating Action API settings arrays during CI. Some of that logic should be part of ParamValidator instead. Bug: T242887 Change-Id: I3c3d23e38456de19179ae3e5855397316b6e4c40 Depends-On: I04de72d731b94468d8a12b35df67f359382b3742
* API: Use ParamValidator libraryBrad Jorsch2020-02-043-0/+557
This brings significant modularization to the Action API's parameter validation, and allows the Action API and MW REST API to share validation code. Note there are several changes in this patch that may affect other code; see the entries in RELEASE-NOTES-1.35 for details. Bug: T142080 Bug: T232672 Bug: T21195 Bug: T34675 Bug: T154774 Change-Id: I1462edc1701278760fa695308007006868b249fc Depends-On: I10011be060fe6d27c7527312ad41218786b3f40d