From ea57223bfea9a520a613958c6289d4df02baadb5 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Wed, 14 Sep 2011 19:57:41 +0000 Subject: [PATCH] FU r89706: Cleaned up getParserOptions duplication problems --- includes/WikiPage.php | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/includes/WikiPage.php b/includes/WikiPage.php index 817a1d274b..c177115634 100644 --- a/includes/WikiPage.php +++ b/includes/WikiPage.php @@ -2563,21 +2563,13 @@ class WikiPage extends Page { * Get parser options suitable for rendering the primary article wikitext * @param $canonical boolean Determines that the generated options must not depend on user preferences (see bug 14404) * @return mixed ParserOptions object or boolean false + * @deprecated since 1.19 */ public function getParserOptions( $canonical = false ) { global $wgUser, $wgLanguageCode; - if ( !$this->mParserOptions || $canonical ) { $user = !$canonical ? $wgUser : new User; - $parserOptions = new ParserOptions( $user ); - $parserOptions->setTidy( true ); - $parserOptions->enableLimitReport(); - - if ( $canonical ) { - $parserOptions->setUserLang( $wgLanguageCode ); # Must be set explicitely - return $parserOptions; - } - $this->mParserOptions = $parserOptions; + $this->mParserOptions = $this->makeParserOptions( $user ); } // Clone to allow modifications of the return value without affecting cache return clone $this->mParserOptions; @@ -2589,9 +2581,13 @@ class WikiPage extends Page { * @return ParserOptions */ public function makeParserOptions( User $user ) { + global $wgLanguageCode; $options = ParserOptions::newFromUser( $user ); $options->enableLimitReport(); // show inclusion/loop reports $options->setTidy( true ); // fix bad HTML + if ( $user->isAnon() ) { + $options->setUserLang( $wgLanguageCode ); # Must be set explicitily + } return $options; } -- 2.20.1