aboutsummaryrefslogtreecommitdiffstats
path: root/includes/http
Commit message (Collapse)AuthorAgeFilesLines
* Replace call_user_func with dynamic function callUmherirrender2025-02-131-1/+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
* build: Updating mediawiki/mediawiki-codesniffer to 46.0.0libraryupgrader2025-01-311-1/+1
| | | | Change-Id: I0f8a8cac36015bba52aea3ee2affd92f83d3574a
* Remove 2-line PHPDocs that just repeat the types from the codethiemowmde2025-01-172-10/+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-162-4/+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
* HttpRequestFactory: use Tracer telemetryChris Danis2025-01-131-2/+3
| | | | | | | | This will attach HTTP request spans to the Mediawiki-created span, instead of the Envoy-created span. Bug: T340552 Change-Id: Icf61c35468bce41fe3f7051221f2b81c55030166
* Merge "Replace isset() with null checks"jenkins-bot2024-12-191-1/+1
|\
| * Replace isset() with null checksUmherirrender2024-12-191-1/+1
| | | | | | | | | | | | | | | | | | 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: Ib84b7d71e8308a36409f30ecfd16e9de149e97b3
* | Replace isset() with falsy checksUmherirrender2024-12-191-1/+1
|/ | | | | | | | | 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
* MWHttpRequest: allow using local proxy in cli modeGiuseppe Lavagetto2024-12-031-4/+1
| | | | | | | | | | | | | | | | | | | | | | As stated in the linked task, it is not guaranteed that we can't serve "local" requests in cli mode. This is only true if the following assumptions are also true: * you run the cli scripts on a different machine as the webserver * You don't run a service mesh to mediate between MediaWiki and the external services While the former is true for the wikimedia production setup, it's not a common setup at all. On the other hand, it's been quite a few years since Wikimedia started using a service mesh. So it seems to me that for the absolute majority of installations, this condtional was actually harmful. This patch allows using the local proxy also in cli mode, and puts control back in the hands of the system administrators. Bug: T381251 Change-Id: I724a1e840d586db2b6b57b9990a5747290e39494
* Fix some more bool/null message paramsBartosz Dziewoński2024-11-031-1/+1
| | | | | | | | Found by Phan thanks to the type hints being added in I3e0df790ff9db2fa630f82408a7254a359fe61ca. Bug: T378876 Change-Id: I286a4a51e879bdf61f65c87dc078621c51045bee
* Use explicit nullable type on parameter argumentsUmherirrender2024-10-164-4/+4
| | | | | | | | | | | Implicitly marking parameter $... as nullable is deprecated in php8.4, the explicit nullable type must be used instead Created with autofix from Ide15839e98a6229c22584d1c1c88c690982e1d7a Break one long line in SpecialPage.php Bug: T376276 Change-Id: I807257b2ba1ab2744ab74d9572c9c3d3ac2a968e
* Add @phan-mandatory-param for function name argumentsUmherirrender2024-09-203-6/+6
| | | | | | | | | | | Providing the function name is often optional from the php code, but it is needed for better logging, so make it mandatory and let phan report issues about this. Bug: T374546 Depends-On: Iaed5489a85a5a6e685829e151436afc94310fbd0 Depends-On: Ie2a1e5052e5b61bbb5b89905de942f47d3f1413d Change-Id: I5227f2fa65850ac8c6f620900f22d1f4e7bfd470
* Merge "http: Remove timestamp from 'http' channel logs"jenkins-bot2024-09-171-1/+1
|\
| * http: Remove timestamp from 'http' channel logsBartosz Dziewoński2024-09-171-1/+1
| | | | | | | | | | | | | | | | The timestamp is redundant with the timestamp that should be injected by the log formatter, and it makes it more difficult to find identical log messages. Change-Id: Ifa0529a5f8233be5adc16fa7632542f39916fda9
* | Remove unchecked exception annotationsAdam Wight2024-09-171-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Callers should not catch an unchecked exception, so it doesn't belong in a function signature. Unchecked exceptions indicate a coding error, which by definition the code will not be able to handle correctly. If any of these exceptions were supposed to be in response to an edge case, user input, or initial conditions, then they should be changed to a runtime error. If the exception class cannot be changed, then the annotation should include a comment explaining its purpose and prognosis. Bug: T240672 Change-Id: I2e640b9737cb68090a8e1cb70067d1b74037d647
* | http: Add missing documentation to class propertiesUmherirrender2024-09-143-0/+21
|/ | | | | | | | | | Add doc-typehints to class properties found by the PropertyDocumentation sniff to improve the documentation. Once the sniff is enabled it avoids that new code is missing type declarations. This is focused on documentation and does not change code. Change-Id: I6dd402a5bca0c2136595faedae315959bbcf17d9
* Migrate all uses of deprecated URL global functions to use wfGetUrlUtils()James D. Forrester2024-09-101-3/+3
| | | | | | | | | | | | | | wfGetUrlUtils() is also deprecated, but less so, so we can do this first and then properly replace the individual uses with dependency injection in local pieces of work. Also: * Switching Parser::getExternalLinkRel to UrlUtils::matchesDomainList exposed a type error in media.txt where $wgNoFollowDomainExceptions was set to a string (which is invalid) instead of an array. Bug: T319340 Change-Id: Icb512d7241954ee155b64c57f3782b86acfd9a4c
* Avoid use of deprecated global functions in MWHttpRequestEbrahim Byagowi2024-09-091-4/+8
| | | | | Bug: T319340 Change-Id: I757180bd8aa59bd51bd42661724dc99f8d56016f
* Replace a few more uses of deprecated Status / StatusValue methodsBartosz Dziewoński2024-08-221-1/+1
| | | | Change-Id: I017bcaffe6945d633d7387f9391803845369bfed
* Add namespace and deprecation alias to MultiHttpClientEbrahim Byagowi2024-05-201-1/+1
| | | | | | | | | This patch introduces a namespace declaration for the Wikimedia\Http to MultiHttpClient and establishes a class alias marked as deprecated since version 1.43. Bug: T353458 Change-Id: I4ebc1a3b496de08b2b430301da376578d13fcfe6
* Do not mark HttpRequestFactory as @internalMartin Urbanec2024-05-131-1/+0
| | | | | | | | | | | | | | | The @internal annotation was added in I3e5e54afa21f8c099877b3765c769f2d2f8f5d61 with no explanation. The current annotations advise extensions to not use HttpRequestFactory, which renders extensions unable to make HTTP requests when they need to. This appears to be a declaration added by a mistake, intending to make the constructor itself as @internal. Since constructors are unstable by default, this patch removes the @internal annotation with no replacement. Change-Id: I9696034fb014c6a87b4532bff22d8c9d494e9bb1
* MWHttpRequest: Drop support for creating without timeout or ↵Piotr Miazga2024-05-051-22/+8
| | | | | | | | | | | connectionTimeout, deprecated in 1.35 In 1.35 we deprecated not passing the timeout and connectionTimeout settings when constructing the MWHttpRequest object. Upgrade hard-deprecation via wfDeprecated() to instead throw an InvalidArgumentException. Change-Id: I260469c6235fa9022b264757b0a17d498cee1396
* build: Resolve MediaWikiNoEmptyIfDefined suppressionUmherirrender2024-02-141-2/+1
| | | | | Follow-Up: Id183ab60994cd9c6dc80401d4ce4de0ddf2b3da0 Change-Id: Iac6aa104331ffc26460f8360b252e03d2307e6fd
* build: Upgrade mediawiki/mediawiki-phan-config from 0.13.0 to 0.14.0 manuallyJames D. Forrester2024-02-102-2/+3
| | | | | | | | | | | * Switch out raw Exceptions, mostly for InvalidArgumentExceptions. * Fake exceptions triggered to give Monolog a backtrace are for some reason "traditionally" RuntimeExceptions, instead, so we continue to use that pattern in remaining locations. * Just entirely give up on PostgresResultWrapper's resource vs. object mess. * Drop now-unneeded false positive hits. Change-Id: Id183ab60994cd9c6dc80401d4ce4de0ddf2b3da0
* Use the instanceof and ::class features instead of stringsthiemowmde2024-02-021-5/+3
| | | | | | | | | | This makes it much easier for IDEs and tools like Phan to understand what's going on. Note this syntax is perfectly valid even if a class is undefined. Language features like `use`, `instanceof`, and `class_exists` work perfectly fine. We do this a lot in existing code. Change-Id: I4d397621ebcc6a7e842150f7641c1b23d082b730
* Replace $wgCommandLineMode checks with MW_ENTRY_POINT in other placesBartosz Dziewoński2024-01-021-4/+3
| | | | | | | | I'm not sure if there's a good way to split this up into logical chunks. Bug: T313841 Change-Id: I3b35a2e475b5143f383d4085fbc6a0ed3bbc32b8
* shellbox: Use Telemetry class instead of WebRequest::getRequestId()Piotr Miazga2023-09-191-0/+5
| | | | | | | | | | ShellboxClientFactory should depend upon HttpRequestFactory to provide a fully initialized HTTP Client. It shouldn't handle things like `X-Request-Id` as it's HTTP layer responsibility. More over the `WebRequest::getRequestId()` got deprecated in favour of Telemetry class. Bug: T346209 Change-Id: If7630f81be4d7ca94ab0cac02b2a30126e3a297d
* Merge "http: MultiHttpClient supports TelemetryHeadersInterface"jenkins-bot2023-09-123-12/+20
|\
| * http: MultiHttpClient supports TelemetryHeadersInterfacePiotr Miazga2023-09-123-12/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Introduce a new interface Wikimedia/Http/TelemetryHeadersInterface that provides telemetry information that could be attached to HTTP Requests. MultiHttpClient is expecting `telemetry` option of TelemetryHeadersInterface type. The MediaWiki/Http/Telemetry implements the interface, therefore ObjectCache can inject it to RESTBagOStuff, that further injects it to MultiHttpClient. Bug: T344926 Change-Id: I59a3f1048c403fe2e4ef0c74353dfe74ff9ca893
* | Reorg: Move WebRequest to includes\RequestAmir Sarabadani2023-09-112-1/+2
|/ | | | | | | This has been approved as part of RFC T166010 Bug: T321882 Change-Id: I6bbdbbe6ea48cc1f50bc568bb8780fc7c5361a6f
* HttpRequestFactory: Minor cleanupReedy2023-08-261-10/+7
| | | | Change-Id: Ia764e1b4a4d306ab4fe294aa45fd0f8306810b19
* Reorg: Move Status to MediaWiki\Status\Amir Sarabadani2023-08-253-1/+3
| | | | | | | | | | This class is used heavily basically everywhere, moving it to Utils wouldn't make much sense. Also with this change, we can move StatusValue to MediaWiki\Status as well. Bug: T321882 Depends-On: I5f89ecf27ce1471a74f31c6018806461781213c3 Change-Id: I04c1dcf5129df437589149f0f3e284974d7c98fa
* http: fix JobRunner overriding requestId with nullPiotr Miazga2023-08-091-0/+9
| | | | | | | | | | | | | After deploying T320559 we found out that JobRunner sometimes calls the WebRequest::overrideRequestId() with a null. This caused the TelemetryService to fail due to $newId not being a string. As a solution there is a new method called regenerateRequestId() that will handle the regeneration as it's recommended to keep the overrideRequestId() strict. Bug: T343893 Change-Id: I3e6daa238fd8de0d9ea88660b8ba32b922b1323d
* http: Propagate `tracestate` and `traceparent` headersPiotr Miazga2023-08-073-5/+153
| | | | | | | | | | | Introduce a Telemetry singleton for propagating `tracestate` and `traceheaders` during a MW web request. This class allows for easier testing and mocking. In the future we might use this as a wrapper for OpenTelemetry. Bug: T320559 Change-Id: I3e5e54afa21f8c099877b3765c769f2d2f8f5d61
* Remove deprecated MWHttpRequest::factoryUmherirrender2023-04-261-16/+0
| | | | | Bug: T324918 Change-Id: Ie03d4b25eb239bbbbc2346821a86f09c29e03524
* Remove deprecated class HttpUmherirrender2023-04-241-152/+0
| | | | | | | | | | | | | | The class and all functions are deprecated: - Http::request() - Http::get() - Http::post() - Http::userAgent() - Http::isValidURI() - Http::getProxy() - Http::createMultiClient() Bug: T305813 Change-Id: Icd8af4822b16b4bf4558b756e20171c3ae9a9fa1
* Merge "Hard-deprecate Http::request/get/post/userAgent/isValidURI"jenkins-bot2023-02-231-5/+10
|\
| * Hard-deprecate Http::request/get/post/userAgent/isValidURIUmherirrender2023-02-131-5/+10
| | | | | | | | | | | | | | | | | | | | | | * Http::request * Http::get * Http::post * Http::userAgent * Http::isValidURI Bug: T305813 Change-Id: I4f8410f43128c0f53742cca055027c2e9ebcde44
* | Hard-deprecate MWHttpRequest::factoryUmherirrender2023-02-131-1/+2
|/ | | | | Bug: T324918 Change-Id: I360d57b5aa9e2e8cbfc8b5c5654ab1aaf1d944b3
* http: Log GuzzleHttpRequest requestsGergő Tisza2023-02-081-3/+13
| | | | | | | | | | | | | | MwHttpRequest has a logger option, but GuzzleHttpRequest ignored it; fix that. This will log something like [2023-02-08T06:50:29+00:00] GET http://127.0.0.1:22100/ HTTP/1.1 - 301 NULL to the http channel, at level INFO on successful and at level ERROR on failed requests. Change-Id: I2e4067c67aace434ed111a1a09f03888ea43e924
* MWCallbackStream: Add explicit $stream propertyReedy2022-12-271-0/+3
| | | | | Bug: T324895 Change-Id: Ic347beb30b50fe76f02855700f770195a5eabf8a
* Make use of ?:, ?? and ??= operators in mostly trivial casesthiemowmde2022-12-051-4/+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
* Various doc fixes about false on method arguments/return typesUmherirrender2022-11-101-3/+3
| | | | | | Doc-only changes Change-Id: I5177f582ae7ee70c357e9389fed14819faf79463
* Revert "Reorg: Move some of request related classes to MediaWiki/Request"Zabe2022-10-272-5/+4
| | | | | | | | | 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-262-4/+5
| | | | | | | | | | | | | 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
* Use MainConfigNames instead of string literals, #3Aryeh Gregor2022-04-261-22/+24
| | | | | | | | | | | | | This edition brought to you by: grep -ERIn $(grep -o "'[A-Za-z0-9_]*'" includes/MainConfigNames.php | tr "\n" '|' | sed 's/|$/\n/') includes/ I only corrected a fraction of the results provided by that command. I'm submitting the partial patch now so it doesn't bitrot. Bug: T305805 Change-Id: If1918c0b3d88cdf90403921e4310740e206d6962
* Use MainConfigNames instead of string literalsAryeh Gregor2022-04-112-7/+16
| | | | | | | | Part 1, proof of concept. Hundreds of files left to go. These changes brought to you in large part by vim macros. Bug: T305805 Change-Id: I44789091e9f6394c800a11b29f22528c8dcacf71
* Merge "phan: Remove PhanTypePossiblyInvalidDimOffset suppression"jenkins-bot2022-03-291-0/+1
|\
| * 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