Deprecate $wgUseKeyHeader and OutputPage::getKeyHeader()
authorC. Scott Ananian <cscott@cscott.net>
Fri, 12 Oct 2018 15:50:14 +0000 (11:50 -0400)
committerC. Scott Ananian <cscott@cscott.net>
Fri, 12 Oct 2018 17:29:06 +0000 (13:29 -0400)
The `Key` header was a draft IETF specification which expired without
becoming a standard.  It does not appear to be in active use anywhere.

Change-Id: I3924a1b5ff428b107573d2827c40e4af8adaaeb1

RELEASE-NOTES-1.32
includes/DefaultSettings.php
includes/OutputPage.php
tests/phpunit/includes/OutputPageTest.php

index 40dd295..a63a16d 100644 (file)
@@ -531,6 +531,9 @@ because of Phabricator reports.
 * In Skin::doEditSectionLink omitting the parameters $tooltip and $lang is
   deprecated. For the $lang parameter, types other than Language are
   deprecated.
+* The $wgUseKeyHeader configuration option and the
+  OutputPage::getKeyHeader() method have been deprecated; the relevant
+  draft IETF spec expired without becoming a standard.
 
 === Other changes in 1.32 ===
 * (T198811) The following tables have had their UNIQUE indexes turned into
index 4ed1707..6a1ed92 100644 (file)
@@ -2741,8 +2741,9 @@ $wgUseESI = false;
 
 /**
  * Send the Key HTTP header for better caching.
- * See https://datatracker.ietf.org/doc/draft-fielding-http-key/ for details.
+ * See https://datatracker.ietf.org/doc/draft-ietf-httpbis-key/ for details.
  * @since 1.27
+ * @deprecated in 1.32, the IETF spec expired without becoming a standard.
  */
 $wgUseKeyHeader = false;
 
index 17e92cb..cde92e8 100644 (file)
@@ -2281,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 = [];
@@ -2330,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,
index 19494f2..53e6f46 100644 (file)
@@ -2083,6 +2083,7 @@ class OutputPageTest extends MediaWikiTestCase {
                        ->will( $this->returnValue( $cookies ) );
                TestingAccessWrapper::newFromObject( $op )->mVaryHeader = [];
 
+               $this->hideDeprecated( '$wgUseKeyHeader' );
                foreach ( $calls as $call ) {
                        $op->addVaryHeader( ...$call );
                }
@@ -2235,6 +2236,7 @@ class OutputPageTest extends MediaWikiTestCase {
        /**
         * @dataProvider provideAddAcceptLanguage
         * @covers OutputPage::addAcceptLanguage
+        * @covers OutputPage::getKeyHeader
         */
        public function testAddAcceptLanguage(
                $code, array $variants, array $expected, array $options = []
@@ -2262,6 +2264,7 @@ class OutputPageTest extends MediaWikiTestCase {
                // This will run addAcceptLanguage()
                $op->sendCacheControl();
 
+               $this->hideDeprecated( '$wgUseKeyHeader' );
                $keyHeader = $op->getKeyHeader();
 
                if ( !$expected ) {