Merge "feedback: Fix misplaced mw.Title.getNameText() call"
[lhc/web/wiklou.git] / includes / WebRequest.php
index d5b081e..7da092f 100644 (file)
@@ -382,7 +382,7 @@ class WebRequest {
         */
        private function getGPCVal( $arr, $name, $default ) {
                # PHP is so nice to not touch input data, except sometimes:
-               # https://secure.php.net/variables.external#language.variables.external.dot-in-names
+               # https://www.php.net/variables.external#language.variables.external.dot-in-names
                # Work around PHP *feature* to avoid *bugs* elsewhere.
                $name = strtr( $name, '.', '_' );
                if ( isset( $arr[$name] ) ) {
@@ -849,12 +849,19 @@ class WebRequest {
         * in HTML or other output.
         *
         * If $wgServer is protocol-relative, this will return a fully
-        * qualified URL with the protocol that was used for this request.
+        * qualified URL with the protocol of this request object.
         *
         * @return string
         */
        public function getFullRequestURL() {
-               return wfGetServerUrl( PROTO_CURRENT ) . $this->getRequestURL();
+               // 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->getProtocol() === 'http' ) {
+                       return wfGetServerUrl( PROTO_HTTP ) . $this->getRequestURL();
+               } else {
+                       return wfGetServerUrl( PROTO_HTTPS ) . $this->getRequestURL();
+               }
        }
 
        /**