From e18b7e6c7ba98a94d34f66a0685f5b3f9f828ea7 Mon Sep 17 00:00:00 2001 From: Marius Hoch Date: Thu, 15 Nov 2012 23:59:31 +0100 Subject: [PATCH] Make InputBoxes cache ones per language InputBoxes creates HTML which will later be cached (probably). Right now this can lead to strange button labels eg. https://www.wikidata.org/wiki/Wikidata:Requests_for_comment?uselang=qqx&action=purge will cache the qqx of the createarticle button so that all users see it (till it's purged again). To prevent this we set the parser to cache per user language. Change-Id: I69ade88bb43f73404965b7cb63e88b824561d988 --- InputBox.classes.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/InputBox.classes.php b/InputBox.classes.php index ceebf6b8..654af9f7 100644 --- a/InputBox.classes.php +++ b/InputBox.classes.php @@ -41,6 +41,9 @@ class InputBox { $this->mParser = $parser; // Default value for dir taken from the page language (bug 37018) $this->mDir = $this->mParser->getTargetLanguage()->getDir(); + // Split caches by language, to make sure visitors do not see a cached + // version in a random language (since labels are in the user language) + $this->mParser->getOptions()->getUserLangObj(); } public function render() { @@ -64,8 +67,8 @@ class InputBox { 'class' => 'error' ), strlen( $this->mType ) > 0 - ? wfMessage( 'inputbox-error-bad-type', $this->mType )->inContentLanguage()->text() - : wfMessage( 'inputbox-error-no-type' )->inContentLanguage()->text() + ? wfMessage( 'inputbox-error-bad-type', $this->mType )->text() + : wfMessage( 'inputbox-error-no-type' )->text() ) ); }