r83533 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r83532‎ | r83533 | r83534 >
Date:17:57, 8 March 2011
Author:nikerabbit
Status:ok
Tags:
Comment:
Even more tweaking to Special:LanguageStats... should be pretty fast now
Modified paths:
  • /trunk/extensions/Translate/specials/SpecialLanguageStats.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/specials/SpecialLanguageStats.php
@@ -26,8 +26,11 @@
2727 }
2828
2929 function execute( $par ) {
30 - global $wgRequest, $wgOut;
 30+ global $wgRequest, $wgOut, $wgUser;
3131
 32+ $this->linker = $wgUser->getSkin();
 33+ $this->translate = SpecialPage::getTitleFor( 'Translate' );
 34+
3235 $this->setHeaders();
3336 $this->outputHeader();
3437
@@ -48,7 +51,6 @@
4952 }
5053
5154 if ( !$code ) {
52 - global $wgUser;
5355
5456 if ( $wgUser->isLoggedIn() ) {
5557 global $wgLang;
@@ -318,13 +320,16 @@
319321 }
320322
321323 protected function loadPercentages( $cache, $group, $code ) {
322 - $incache = $cache->get( $group->getId(), $code );
323 - if ( $incache !== false ) {
324 - return $incache;
 324+ wfProfileIn( __METHOD__ );
 325+ $id = $group->getId();
 326+
 327+
 328+ $result = $cache->get( $id, $code );
 329+ if ( is_array( $result ) ) {
 330+ wfProfileOut( __METHOD__ );
 331+ return $result;
325332 }
326333
327 - wfProfileIn( __METHOD__ );
328 -
329334 // Initialise messages.
330335 $collection = $group->initCollection( $code );
331336 // Takes too much memory and only hides inconsistent import state
@@ -344,14 +349,13 @@
345350
346351 $result = array( $fuzzy, $translated, $total );
347352
348 - $cache->set( $group->getId(), $code, $result );
 353+ $cache->set( $id, $code, $result );
349354
350355 static $i = 0;
351 - if ( $i++ % 10 === 0 ) {
 356+ if ( $i++ % 50 === 0 ) {
352357 $cache->commit();
353358 }
354359
355 - unset( $collection );
356360 wfProfileOut( __METHOD__ );
357361
358362 return $result;
@@ -375,26 +379,27 @@
376380 }
377381
378382 protected function makeGroupLink( $group, $code, $params ) {
379 - global $wgOut, $wgUser;
 383+ global $wgOut;
380384
381 - $specialTranslate = SpecialPage::getTitleFor( 'Translate' );
382 - $skin = $wgUser->getSkin();
383 -
384385 $queryParameters = $params + array(
385386 'group' => $group->getId(),
386387 'language' => $code
387388 );
388389
389390 $attributes = array(
390 - 'title' => strip_tags( $wgOut->parse( $group->getDescription(), false ) )
 391+ 'title' => $this->getGroupDescription( $group )
391392 );
392393
393 - $translateGroupLink = $skin->link(
394 - $specialTranslate, $this->getGroupLabel( $group ), $attributes, $queryParameters
 394+ $translateGroupLink = $this->linker->link(
 395+ $this->translate, $this->getGroupLabel( $group ), $attributes, $queryParameters
395396 );
396397
397398 return $translateGroupLink;
 399+ }
398400
 401+ protected function getGroupDescription( $group ) {
 402+ global $wgLang;
 403+ return MessageCache::singleton()->transform( $group->getDescription(), true, $wgLang, $this->getTitle() );
399404 }
400405
401406 protected function isBlacklisted( $groupId, $code ) {

Status & tagging log