Index: trunk/extensions/Translate/Stats.php |
— | — | @@ -448,7 +448,7 @@ |
449 | 449 | |
450 | 450 | if ( $this->filters['group'] ) { |
451 | 451 | $group = TranslateUtils::messageKeyToGroup( $row->rc_namespace, $key ); |
452 | | - if ( $group === null ) return - 1; |
| 452 | + if ( $group === null ) return -1; |
453 | 453 | $indexKey .= $group; |
454 | 454 | } |
455 | 455 | |
Index: trunk/extensions/Translate/utils/StringMatcher.php |
— | — | @@ -17,10 +17,10 @@ |
18 | 18 | protected $aRegex = array(); |
19 | 19 | |
20 | 20 | public static function EmptyMatcher() { |
21 | | - return new StringMatcher( '', array() ); |
| 21 | + return new StringMatcher; |
22 | 22 | } |
23 | 23 | |
24 | | - public function __construct( $prefix, $patterns = array() ) { |
| 24 | + public function __construct( $prefix = '', $patterns = array() ) { |
25 | 25 | $this->sPrefix = $prefix; |
26 | 26 | $this->init( $patterns ); |
27 | 27 | } |
Index: trunk/extensions/Translate/TranslateUtils.php |
— | — | @@ -167,18 +167,28 @@ |
168 | 168 | return $selector->getHTML(); |
169 | 169 | } |
170 | 170 | |
| 171 | + static $mi = null; |
| 172 | + |
171 | 173 | public static function messageKeyToGroup( $namespace, $key ) { |
172 | | - $normkey = self::normaliseKey( $namespace, $key ); |
173 | | - $index = self::messageIndex(); |
174 | | - $group = @$index[$normkey]; |
| 174 | + if ( self::$mi === null ) self::messageIndex(); |
| 175 | + |
| 176 | + # Performance hotspot |
| 177 | + #$normkey = self::normaliseKey( $namespace, $key ); |
| 178 | + $normkey = str_replace( " ", "_", strtolower( "$namespace:$key" ) ); |
| 179 | + |
| 180 | + $group = @self::$mi[$normkey]; |
175 | 181 | if ( is_array($group) ) $group = $group[0]; |
176 | 182 | return $group; |
177 | 183 | } |
178 | 184 | |
179 | 185 | public static function messageKeyToGroups( $namespace, $key ) { |
180 | | - $normkey = self::normaliseKey( $namespace, $key ); |
181 | | - $index = self::messageIndex(); |
182 | | - return (array) @$index[$normkey]; |
| 186 | + if ( self::$mi === null ) self::messageIndex(); |
| 187 | + |
| 188 | + # Performance hotspot |
| 189 | + #$normkey = self::normaliseKey( $namespace, $key ); |
| 190 | + $normkey = str_replace( " ", "_", strtolower( "$namespace:$key" ) ); |
| 191 | + |
| 192 | + return (array) @self::$mi[$normkey]; |
183 | 193 | } |
184 | 194 | |
185 | 195 | public static function normaliseKey( $namespace, $key ) { |
— | — | @@ -186,9 +196,6 @@ |
187 | 197 | } |
188 | 198 | |
189 | 199 | public static function messageIndex() { |
190 | | - static $keyToGroup = null; |
191 | | - if ( $keyToGroup !== null ) return $keyToGroup; |
192 | | - |
193 | 200 | global $wgCacheDirectory; |
194 | 201 | $filename = "$wgCacheDirectory/translate_messageindex.cdb"; |
195 | 202 | if ( !file_exists($filename) ) MessageIndexRebuilder::execute(); |
— | — | @@ -201,6 +208,7 @@ |
202 | 209 | wfDebug( __METHOD__ . ": Message index missing." ); |
203 | 210 | } |
204 | 211 | |
| 212 | + self::$mi = $keyToGroup; |
205 | 213 | return $keyToGroup; |
206 | 214 | } |
207 | 215 | |