diff options
author | Timo Tijhof <krinklemail@gmail.com> | 2019-04-20 00:41:56 +0100 |
---|---|---|
committer | Timo Tijhof <krinklemail@gmail.com> | 2019-04-20 00:58:17 +0100 |
commit | 7929d190b467bb9ecaec02e581c8c548b63ea8ce (patch) | |
tree | 18725aec4b4e4f9a622fa40408a2a29296523dd4 /includes/FauxRequest.php | |
parent | 9d225ee6039c56dae3275ceb96d4a1d9e3c6fe08 (diff) | |
download | mediawikicore-7929d190b467bb9ecaec02e581c8c548b63ea8ce.tar.gz mediawikicore-7929d190b467bb9ecaec02e581c8c548b63ea8ce.zip |
WebRequest: Change getFullRequestURL() to use local getProtocol()
Previously it relied on wfGetServerUrl to decide the url,
which passed PROTO_CURRENT on to wfExpandUrl(), when then uses
global $wgRequest and checks getProtocol() on that.
For typical web requests, these would be the same object by
reference, but the needless indirection makes the code harder
to reason about and harder to test.
Instead, check this locally and pass on an explicit HTTP or HTTPS
to wfGetServerUrl/wfExpandUrl.
Change-Id: I797bd2f909625536c3af36f015fb2e94bf922ba9
Diffstat (limited to 'includes/FauxRequest.php')
-rw-r--r-- | includes/FauxRequest.php | 11 |
1 files changed, 0 insertions, 11 deletions
diff --git a/includes/FauxRequest.php b/includes/FauxRequest.php index 906e5e242d5c..ecbc6e337345 100644 --- a/includes/FauxRequest.php +++ b/includes/FauxRequest.php @@ -170,17 +170,6 @@ class FauxRequest extends WebRequest { return $this->requestUrl; } - public function getFullRequestURL() { - // Pass an explicit PROTO constant instead of PROTO_CURRENT so that we - // do not rely on state from the global $wgRequest object (which it would, - // via wfGetServerUrl/wfExpandUrl/$wgRequest->protocol). - if ( $this->protocol === 'http' ) { - return wfGetServerUrl( PROTO_HTTP ) . $this->getRequestURL(); - } else { - return wfGetServerUrl( PROTO_HTTPS ) . $this->getRequestURL(); - } - } - public function getProtocol() { return $this->protocol; } |