From e2e210e2dee80d0e3d988c7437472b2366cb247a Mon Sep 17 00:00:00 2001 From: Platonides Date: Tue, 28 Dec 2010 18:44:32 +0000 Subject: [PATCH] Fix bug 14404. The articles are now always saved with the default options. Most importantily, articles with {{int:X}} will now have consistent table links no matter the language of the last saving user. Existing articles with broken tables will be updated on a null edit (a purge is not enough). Test added in r79121. --- includes/Article.php | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/includes/Article.php b/includes/Article.php index a2d7b8c63a..5a5677745a 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -41,7 +41,7 @@ class Article { var $mTouched = '19700101000000'; // !< var $mUser = -1; // !< Not loaded var $mUserText = ''; // !< username from Revision if set - var $mParserOptions; // !< ParserOptions object + var $mParserOptions; // !< ParserOptions object for $wgUser articles var $mParserOutput; // !< ParserCache object if set /**@}}*/ @@ -3598,7 +3598,7 @@ class Article { $edit->revid = $revid; $edit->newText = $text; $edit->pst = $this->preSaveTransform( $text ); - $edit->popts = $this->getParserOptions(); + $edit->popts = $this->getParserOptions( true ); $edit->output = $wgParser->parse( $edit->pst, $this->mTitle, $edit->popts, true, true, $revid ); $edit->oldText = $this->getContent(); @@ -4439,15 +4439,23 @@ class Article { /** * Get parser options suitable for rendering the primary article wikitext + * @param $canonical boolean Determines that the generated must not depend on user preferences (see bug 14404) * @return mixed ParserOptions object or boolean false */ - public function getParserOptions() { - global $wgUser; - - if ( !$this->mParserOptions ) { - $this->mParserOptions = new ParserOptions( $wgUser ); - $this->mParserOptions->setTidy( true ); - $this->mParserOptions->enableLimitReport(); + 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; } // Clone to allow modifications of the return value without affecting -- 2.20.1