aboutsummaryrefslogtreecommitdiffstats
path: root/includes/Rest/CorsUtils.php
Commit message (Collapse)AuthorAgeFilesLines
* Remove 2-line PHPDocs that just repeat the types from the codethiemowmde2025-01-171-4/+0
| | | | | | | | | | | | | | | | Same as Ia294bf4 did for 1-line comments. This patch removes slightly more complex 2-line PHPDoc comments that don't add any new information to the code, but literally repeat what the code already says. They say "don't document the code, code the documentation", and we are doing this more and more. We just tend to forget to remove the obsolete comments. Note I'm also removing a line of text in a few cases when it's very short and literally says the same as the method name. Again, such comments add zero new information. Change-Id: I01535404bab458c6c47e48e5456403b7a64198ed
* 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
* Fix misspelled If-Match headerJakob Warkotsch2024-10-251-1/+1
| | | | | | | This was recently reported by a Wikibase REST API user: https://www.wikidata.org/wiki/Wikidata:Report_a_technical_problem#Wikibase_REST_API:_misspelled_CORS_header_value Change-Id: I2d85f5f8d728917ebf039b8528d70951a2b99146
* Remove meaningless @var documentation from constantsthiemowmde2024-10-091-1/+1
| | | | | | | | | A constant is not a variable. The type is hard-coded via the value and can never change. While the extra @var probably doesn't hurt much, it's redundant and error-prone and can't provide any additional information. Change-Id: Iee1f36a1905d9b9c6b26d0684b7848571f0c1733
* Use real type hints for services etc. in includes/Rest/Bartosz Dziewoński2024-06-111-13/+3
| | | | | | | | | | | | | | | | | 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 More could be done, but to keep this patch reasonably sized, I only changed the most obvious and unambiguously correct cases. In some cases, I also removed redundant doc comments on the constructor, and re-ordered the properties to match the constructor. Change-Id: Ifa710fdf4d8d44a2d7244798b787a1b2a58c35a7
* Introduce Modules into the REST frameworkdaniel2024-05-081-2/+2
| | | | | | | Modules group together endpoints by a shared prefix. The idea is that each module has its own version and can generated self-contained self-documentation. This allows clients to have clear expectations about the endpoints of each module, no matter what wiki they are accessing. So far, each wiki may be exposing a different set of endpoints, with no way to provide a spec that describes that set of endpoints in a way that would be consistent across wikis and stable over time. Bug: T362480 Change-Id: Iebcde4645d472d27eee5a30adb6eee12cc7d046b
* REST: Support origin with port in enforcing CORS policyAmmarpad2023-10-031-4/+7
| | | | | Bug: T342128 Change-Id: I74c5e1fb9a7dd0b4c424513ed08b181611ccccfe
* Replace usages of wfParseUrlDaimona Eaytoy2023-08-111-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | wfParseUrl falls back to the global service locator as of I706ef8a5. This will soon be disallowed in unit tests (see I5117eab9), and all the classes updated in this patch are covered by a unit test that would then fail. SiteConfig already has a UrlUtils object available, so just use that. In the other classes, there is no need to inject a UrlUtils service and we can instead adopt parse_url, because these didn't depend on our site-configurable or custom parsing logic. For precedent see also change I6492f5142861513e4a7, I1e76d2f5aef, and lots of other examples in Codesearch for parse_url(). The warnings about parse_url() in UrlUtils.php have been obsolete since about PHP 5.4, when it started to support protocol-relative URLs, non-slash protocols like "mailto", and deal with spaces/newlines correctly (https://3v4l.org/YWUkl). This patch was partly copied from PS 20 of I5117eab9. Co-Authored-by: Timo Tijhof <krinkle@fastmail.com> Change-Id: I98ea4670e842d11598664f058d8c90a900477be4
* Use MainConfigNames instead of string literals, #4Aryeh Gregor2022-04-261-12/+14
| | | | | | | | | | | | | | | | | | | | | Now largely automated: VARS=$(grep -o "'[A-Za-z0-9_]*'" includes/MainConfigNames.php | \ tr "\n" '|' | sed "s/|$/\n/;s/'//g") sed -i -E "s/'($VARS)'/MainConfigNames::\1/g" \ $(grep -ERIl "'($VARS)'" includes/) Then git add -p with lots of error-prone manual checking. Then semi-manually add all the necessary "use" lines: vim $(grep -L 'use MediaWiki\\MainConfigNames;' \ $(git diff --cached --name-only --diff-filter=M HEAD^)) I didn't bother fixing lines that were over 100 characters unless they were over 120 and triggered phpcs. Bug: T305805 Change-Id: I74e0ab511abecb276717ad4276a124760a268147
* build: Updating dependencieslibraryupgrader2021-07-221-4/+4
| | | | | | | | | | | | | | 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
* Make REST CORS allowed headers respect site configuration.Petr Pchelko2021-05-301-5/+9
| | | | | Bug: T268791 Change-Id: I4f10e508730baf5ce276bb71dc354554eed3cfb0
* Handle CORS preflight request and prevent anon users from unsafe methodsDavid Barratt2020-09-211-0/+177
Creates an OPTIONS handler that handles any OPTIONS requests that are not already handled by a handler. CORS has no mechanism to ensure the user is authenticated, so the Router will reject cross-origin requests from anon users. This change allows authenticated users to make cross-origin requests if they authenticate with OAuth or if $wgRestAllowCrossOriginCookieAuth is enabled. Bug: T232176 Bug: T262712 Change-Id: I128b4bdbec4f6bea35142153c951fd7b79617106