r45515 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r45514‎ | r45515 | r45516 >
Date:20:20, 7 January 2009
Author:ialex
Status:reverted (Comments)
Tags:
Comment:
Fix for r45512: cache the result of LanguageGetLocalizedLanguageNames hook so that it's only run once
Modified paths:
  • /trunk/phase3/languages/Language.php (modified) (history)

Diff [purge]

Index: trunk/phase3/languages/Language.php
@@ -55,6 +55,7 @@
5656 class Language {
5757 var $mConverter, $mVariants, $mCode, $mLoaded = false;
5858 var $mMagicExtensions = array(), $mMagicHookDone = false;
 59+ var $mLocalizedLanguagesNames = null;
5960
6061 static public $mLocalisationKeys = array(
6162 'fallback', 'namespaceNames', 'mathNames', 'bookstoreList',
@@ -410,6 +411,19 @@
411412 }
412413
413414 /**
 415+ * Get localized language names
 416+ *
 417+ * @return array
 418+ */
 419+ function getLocalizedLanguageNames() {
 420+ if( !is_array( $this->mLocalizedLanguagesNames ) ) {
 421+ $this->mLocalizedLanguagesNames = array();
 422+ wfRunHooks( 'LanguageGetLocalizedLanguageNames', array( &$this->mLocalizedLanguagesNames, $this->getCode() ) );
 423+ }
 424+ return $this->mLocalizedLanguagesNames;
 425+ }
 426+
 427+ /**
414428 * Get a message from the MediaWiki namespace.
415429 *
416430 * @param $msg String: message name
@@ -431,8 +445,7 @@
432446 return '';
433447 }
434448 if( $localized ) {
435 - $languageNames = array();
436 - wfRunHooks( 'LanguageGetLocalizedLanguageNames', array( &$languageNames, $this->getCode() ) );
 449+ $languageNames = $this->getLocalizedLanguageNames();
437450 return isset( $languageNames[$code] ) ? $languageNames[$code] : $names[$code];
438451 } else {
439452 return $names[$code];

Follow-up revisions

RevisionCommit summaryAuthorDate
r45829self revert r45512, r45513 and r45515 for now...raymond08:56, 17 January 2009

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r45512* Extend language::getLanguageName to return localized language names if avai...raymond19:19, 7 January 2009

Comments

#Comment by Brion VIBBER (talk | contribs)   18:43, 13 January 2009

followup to fixme r45512

#Comment by Raymond (talk | contribs)   08:57, 17 January 2009

Reverted with r45829 for now.

Status & tagging log