X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FWebRequest.php;h=6593e49d8a219aa7d3250617778ed836f75b416c;hb=14eaaca6024ab29d13afbb1c47e3d23674b185a7;hp=d5b081e624a2e05c71e28fc4498d0b714f99e6b1;hpb=9aed0482f429ae0a06c5f4e3b16d5562449790ca;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/WebRequest.php b/includes/WebRequest.php index d5b081e624..6593e49d8a 100644 --- a/includes/WebRequest.php +++ b/includes/WebRequest.php @@ -275,8 +275,18 @@ class WebRequest { public static function getRequestId() { // This method is called from various error handlers and should be kept simple. - if ( !self::$reqId ) { - self::$reqId = $_SERVER['UNIQUE_ID'] ?? wfRandomString( 24 ); + if ( self::$reqId ) { + return self::$reqId; + } + + global $wgAllowExternalReqID; + + self::$reqId = $_SERVER['UNIQUE_ID'] ?? wfRandomString( 24 ); + if ( $wgAllowExternalReqID ) { + $id = RequestContext::getMain()->getRequest()->getHeader( 'X-Request-Id' ); + if ( $id ) { + self::$reqId = $id; + } } return self::$reqId; @@ -382,7 +392,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 +859,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(); + } } /** @@ -1123,7 +1140,7 @@ HTML; /** * Parse the Accept-Language header sent by the client into an array * - * @return array Array( languageCode => q-value ) sorted by q-value in + * @return array [ languageCode => q-value ] sorted by q-value in * descending order then appearing time in the header in ascending order. * May contain the "language" '*', which applies to languages other than those explicitly listed. * This is aligned with rfc2616 section 14.4