From 6258e5e55cd78e4f5c9e1a4d27430e48340752f1 Mon Sep 17 00:00:00 2001 From: "C. Scott Ananian" Date: Fri, 12 Oct 2018 11:50:14 -0400 Subject: [PATCH] Deprecate $wgUseKeyHeader and OutputPage::getKeyHeader() 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 | 3 +++ includes/DefaultSettings.php | 3 ++- includes/OutputPage.php | 14 ++++++++++++++ tests/phpunit/includes/OutputPageTest.php | 3 +++ 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/RELEASE-NOTES-1.32 b/RELEASE-NOTES-1.32 index 40dd295463..a63a16d293 100644 --- a/RELEASE-NOTES-1.32 +++ b/RELEASE-NOTES-1.32 @@ -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 diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 4ed17074d4..6a1ed925da 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -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; diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 17e92cbfea..cde92e8c17 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -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, diff --git a/tests/phpunit/includes/OutputPageTest.php b/tests/phpunit/includes/OutputPageTest.php index 19494f2dfa..53e6f464c9 100644 --- a/tests/phpunit/includes/OutputPageTest.php +++ b/tests/phpunit/includes/OutputPageTest.php @@ -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 ) { -- 2.20.1