r43399 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r43398‎ | r43399 | r43400 >
Date:00:11, 12 November 2008
Author:tstarling
Status:old
Tags:
Comment:
Fixed fallback feature broken by r43398.
Modified paths:
  • /trunk/phase3/languages/Language.php (modified) (history)

Diff [purge]

Index: trunk/phase3/languages/Language.php
@@ -131,16 +131,21 @@
132132 );
133133
134134 /**
135 - * Get a language object for a given language code
 135+ * Get a cached language object for a given language code
136136 */
137137 static function factory( $code ) {
 138+ if ( !isset( self::$mLangObjCache[$code] ) ) {
 139+ self::$mLangObjCache[$code] = self::newFromCode( $code );
 140+ }
 141+ return self::$mLangObjCache[$code];
 142+ }
 143+
 144+ /**
 145+ * Create a language object for a given language code
 146+ */
 147+ protected static function newFromCode( $code ) {
138148 global $IP;
139149 static $recursionLevel = 0;
140 -
141 - if ( isset( self::$mLangObjCache[$code] ) ) {
142 - return self::$mLangObjCache[$code];
143 - }
144 -
145150 if ( $code == 'en' ) {
146151 $class = 'Language';
147152 } else {
@@ -161,14 +166,12 @@
162167 if( ! class_exists( $class ) ) {
163168 $fallback = Language::getFallbackFor( $code );
164169 ++$recursionLevel;
165 - $lang = Language::factory( $fallback );
 170+ $lang = Language::newFromCode( $fallback );
166171 --$recursionLevel;
167172 $lang->setCode( $code );
168173 } else {
169174 $lang = new $class;
170175 }
171 -
172 - self::$mLangObjCache[$code] = $lang;
173176 return $lang;
174177 }
175178

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r43398Language object cache, for faster wfMsg() performance with unusual languages,...tstarling23:26, 11 November 2008

Status & tagging log