Localisation updates from https://translatewiki.net.
[lhc/web/wiklou.git] / includes / OutputPage.php
index b1874b9..cde92e8 100644 (file)
@@ -323,6 +323,11 @@ class OutputPage extends ContextSource {
         */
        private $CSPNonce;
 
+       /**
+        * @var array A cache of the names of the cookies that will influence the cache
+        */
+       private static $cacheVaryCookies = null;
+
        /**
         * Constructor for OutputPage. This should not be called directly.
         * Instead a new RequestContext should be created and it will implicitly create
@@ -2100,6 +2105,9 @@ class OutputPage extends ContextSource {
        /**
         * Parse wikitext, strip paragraphs, and return the HTML.
         *
+        * @todo This doesn't work as expected at all.  If $interface is false, there's always a
+        * wrapping <div>, so stripOuterParagraph() does nothing.
+        *
         * @param string $text
         * @param bool $linestart Is this the start of a line?
         * @param bool $interface Use interface language (instead of content language) while parsing
@@ -2144,8 +2152,6 @@ class OutputPage extends ContextSource {
         * @param string|int|float|bool|null $mtime Last-Modified timestamp
         * @param int $minTTL Minimum TTL in seconds [default: 1 minute]
         * @param int $maxTTL Maximum TTL in seconds [default: $wgSquidMaxage]
-        * @return int TTL in seconds passed to lowerCdnMaxage() (may not be the same as the new
-        *  s-maxage)
         * @since 1.28
         */
        public function adaptCdnTTL( $mtime, $minTTL = 0, $maxTTL = 0 ) {
@@ -2156,13 +2162,11 @@ class OutputPage extends ContextSource {
                        return $minTTL; // entity does not exist
                }
 
-               $age = time() - wfTimestamp( TS_UNIX, $mtime );
+               $age = MWTimestamp::time() - wfTimestamp( TS_UNIX, $mtime );
                $adaptiveTTL = max( 0.9 * $age, $minTTL );
                $adaptiveTTL = min( $adaptiveTTL, $maxTTL );
 
                $this->lowerCdnMaxage( (int)$adaptiveTTL );
-
-               return $adaptiveTTL;
        }
 
        /**
@@ -2182,19 +2186,18 @@ class OutputPage extends ContextSource {
         * @return array
         */
        function getCacheVaryCookies() {
-               static $cookies;
-               if ( $cookies === null ) {
+               if ( self::$cacheVaryCookies === null ) {
                        $config = $this->getConfig();
-                       $cookies = array_merge(
+                       self::$cacheVaryCookies = array_values( array_unique( array_merge(
                                SessionManager::singleton()->getVaryCookies(),
                                [
                                        'forceHTTPS',
                                ],
                                $config->get( 'CacheVaryCookies' )
-                       );
-                       Hooks::run( 'GetCacheVaryCookies', [ $this, &$cookies ] );
+                       ) ) );
+                       Hooks::run( 'GetCacheVaryCookies', [ $this, &self::$cacheVaryCookies ] );
                }
-               return $cookies;
+               return self::$cacheVaryCookies;
        }
 
        /**
@@ -2278,8 +2281,12 @@ class OutputPage extends ContextSource {
         * Get a complete Key header
         *
         * @return string
+        * @deprecated in 1.32; the IETF spec for this header expired w/o becoming
+        *   a standard.
         */
        public function getKeyHeader() {
+               wfDeprecated( '$wgUseKeyHeader', '1.32' );
+
                $cvCookies = $this->getCacheVaryCookies();
 
                $cookiesOption = [];
@@ -2327,6 +2334,16 @@ class OutputPage extends ContextSource {
                                        continue;
                                }
 
+                               // XXX Note that this code is not strictly correct: we
+                               // do a case-insensitive match in
+                               // LanguageConverter::getHeaderVariant() while the
+                               // (abandoned, draft) spec for the `Key` header only
+                               // allows case-sensitive matches.  To match the logic
+                               // in LanguageConverter::getHeaderVariant() we should
+                               // also be looking at fallback variants and deprecated
+                               // mediawiki-internal codes, as well as BCP 47
+                               // normalized forms.
+
                                $aloption[] = "substr=$variant";
 
                                // IE and some other browsers use BCP 47 standards in their Accept-Language header,