From d21e271c9248121c04955d5c1406c9cc4f32c4d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20Laxstr=C3=B6m?= Date: Fri, 10 Jun 2016 10:04:02 +0200 Subject: [PATCH] Do not output accept language list if it might get cached Bug: T137522 Change-Id: Ib603f836f59f7078ac5dbb7bbbb3b84ca358cb43 --- UniversalLanguageSelector.hooks.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/UniversalLanguageSelector.hooks.php b/UniversalLanguageSelector.hooks.php index ea648dfe..6326246e 100644 --- a/UniversalLanguageSelector.hooks.php +++ b/UniversalLanguageSelector.hooks.php @@ -344,8 +344,14 @@ class UniversalLanguageSelectorHooks { * @return bool */ public static function addVariables( &$vars, OutputPage $out ) { + global $wgULSAnonCanChangeLanguage; + // Place request context dependent stuff here - $vars['wgULSAcceptLanguageList'] = array_keys( $out->getRequest()->getAcceptLang() ); + + // Do not output accept languages if there is risk it will get cached accross requests + if ( $wgULSAnonCanChangeLanguage || $out->getUser()->isLoggedIn() ) { + $vars['wgULSAcceptLanguageList'] = array_keys( $out->getRequest()->getAcceptLang() ); + } // An optimization to avoid loading all of uls.data just to get the autonym $langCode = $out->getLanguage()->getCode();