diff options
author | Timo Tijhof <krinklemail@gmail.com> | 2019-04-20 00:35:15 +0100 |
---|---|---|
committer | Timo Tijhof <krinklemail@gmail.com> | 2019-04-20 00:57:49 +0100 |
commit | 9d225ee6039c56dae3275ceb96d4a1d9e3c6fe08 (patch) | |
tree | ff6b61bd486c0fa5fff234d900225887c1b83833 /includes/FauxRequest.php | |
parent | 86c13ba3ad15f7ab4c567b30c2810fe36db102df (diff) | |
download | mediawikicore-9d225ee6039c56dae3275ceb96d4a1d9e3c6fe08.tar.gz mediawikicore-9d225ee6039c56dae3275ceb96d4a1d9e3c6fe08.zip |
FauxRequest: Remove influence from $wgRequest on getFullRequestURL()
It inherited the method from WebRequest, which in turn uses
PROTO_CURRENT, which indirectly makes it then look up $wgRequest->protocol
to decide how to expand the url.
This global state isn't expected from FauxRequest and makes its
result less than predictable.
Change-Id: Ia616e0bfa00c35f78d27db55f26b336a7d0c7606
Diffstat (limited to 'includes/FauxRequest.php')
-rw-r--r-- | includes/FauxRequest.php | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/includes/FauxRequest.php b/includes/FauxRequest.php index ecbc6e337345..906e5e242d5c 100644 --- a/includes/FauxRequest.php +++ b/includes/FauxRequest.php @@ -170,6 +170,17 @@ 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; } |