Merge "Fix return type of GenerateSitemap::getPageRes"
[lhc/web/wiklou.git] / includes / WebRequest.php
index 7da092f..6593e49 100644 (file)
@@ -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;
@@ -1130,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