r97091 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r97090‎ | r97091 | r97092 >
Date:19:57, 14 September 2011
Author:aaron
Status:resolved (Comments)
Tags:lamecommitsummary 
Comment:
FU r89706: Cleaned up getParserOptions duplication problems
Modified paths:
  • /trunk/phase3/includes/WikiPage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/WikiPage.php
@@ -2563,21 +2563,13 @@
25642564 * Get parser options suitable for rendering the primary article wikitext
25652565 * @param $canonical boolean Determines that the generated options must not depend on user preferences (see bug 14404)
25662566 * @return mixed ParserOptions object or boolean false
 2567+ * @deprecated since 1.19
25672568 */
25682569 public function getParserOptions( $canonical = false ) {
25692570 global $wgUser, $wgLanguageCode;
2570 -
25712571 if ( !$this->mParserOptions || $canonical ) {
25722572 $user = !$canonical ? $wgUser : new User;
2573 - $parserOptions = new ParserOptions( $user );
2574 - $parserOptions->setTidy( true );
2575 - $parserOptions->enableLimitReport();
2576 -
2577 - if ( $canonical ) {
2578 - $parserOptions->setUserLang( $wgLanguageCode ); # Must be set explicitely
2579 - return $parserOptions;
2580 - }
2581 - $this->mParserOptions = $parserOptions;
 2573+ $this->mParserOptions = $this->makeParserOptions( $user );
25822574 }
25832575 // Clone to allow modifications of the return value without affecting cache
25842576 return clone $this->mParserOptions;
@@ -2589,9 +2581,13 @@
25902582 * @return ParserOptions
25912583 */
25922584 public function makeParserOptions( User $user ) {
 2585+ global $wgLanguageCode;
25932586 $options = ParserOptions::newFromUser( $user );
25942587 $options->enableLimitReport(); // show inclusion/loop reports
25952588 $options->setTidy( true ); // fix bad HTML
 2589+ if ( $user->isAnon() ) {
 2590+ $options->setUserLang( $wgLanguageCode ); # Must be set explicitily
 2591+ }
25962592 return $options;
25972593 }
25982594

Follow-up revisions

RevisionCommit summaryAuthorDate
r97173Merged revisions 97087,97091-97092,97094,97096-97098,97100-97101,97103,97136,...dantman16:19, 15 September 2011
r97206Follow up r89706, building up on r97091....platonides21:09, 15 September 2011
r98418Fix for r97091: Extensions can cause anons to have their own language setting...aaron17:39, 29 September 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r89706Reinstate r79122 (fix for bug 14404), reverting r83868. The real bug seem to ...platonides22:28, 7 June 2011

Comments

#Comment by Nikerabbit (talk | contribs)   05:15, 15 September 2011

$wgLanguageCode is now unused.

#Comment by Platonides (talk | contribs)   21:06, 15 September 2011

I see many instances of it.

#Comment by Nikerabbit (talk | contribs)   05:55, 16 September 2011

In getParserOptions?

#Comment by Platonides (talk | contribs)   20:27, 15 September 2011

Why deprecated? It's still called by Article. And if it wasn't, it should just be removed, since nothing would be calling it (it's now in a different class).

#Comment by Platonides (talk | contribs)   21:12, 15 September 2011

Appears to be good. I removed the @deprecated in r97206 (however I was wrong, and extensions could be calling it through __call). I'm not sure if the cost of creating a ParserOptions is worth keeping $this->mParserOptions.

#Comment by Nikerabbit (talk | contribs)   16:18, 29 September 2011

This seems to break LanguageSelector by not taking account that anonymous users might have an different interface language too.

Status & tagging log