r112816 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r112815‎ | r112816 | r112817 >
Date:16:09, 1 March 2012
Author:nikerabbit
Status:ok
Tags:
Comment:
Try to avoid relative expensive queries by using MessageGroupStats framework to get the number of fuzzy messages
Modified paths:
  • /trunk/extensions/Translate/tag/PageTranslationHooks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/tag/PageTranslationHooks.php
@@ -551,10 +551,11 @@
552552 $wgOut->wrapWikiMsg( $wrap, array( 'tpt-translation-intro', $url, $titleText, $per ) );
553553
554554 if ( floor( $per ) < 100 ) {
555 - $group = $page->getMessageGroup();
556 - $collection = $group->initCollection( $code );
557 - $collection->filter( 'fuzzy', false );
558 - if ( count( $collection ) ) {
 555+ $groupId = $page->getMessageGroup()->getId();
 556+ $stats = MessageGroupStats::forItem( $groupId, $code );
 557+ $fuzzy = $stats[MessageGroupStats::FUZZY];
 558+ if ( $fuzzy ) {
 559+ // Only show if there is fuzzy messages
559560 $wrap = '<div class="mw-translate-page-info mw-translate-fuzzy">$1</div>';
560561 $wgOut->wrapWikiMsg( $wrap, array( 'tpt-translation-intro-fuzzy' ) );
561562 }

Status & tagging log