r114371 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r114370‎ | r114371 | r114372 >
Date:14:23, 21 March 2012
Author:nikerabbit
Status:ok
Tags:
Comment:
Simple patch to avoid over counting message groups that are listed multiple times under different parents.
Keeps track of the groups already counted and skips them on subsequent times.
Another kind of overcounting can still happen with groups that share messages.
Modified paths:
  • /trunk/extensions/Translate/specials/SpecialLanguageStats.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/specials/SpecialLanguageStats.php
@@ -77,6 +77,15 @@
7878 */
7979 protected $purge;
8080
 81+ /**
 82+ * Helper variable to avoid overcounting message groups that appear
 83+ * multiple times in the list with different parents. Aggregate message
 84+ * group stats are always excluded from totals.
 85+ *
 86+ * @var array
 87+ */
 88+ protected $statsCounted = array();
 89+
8190 public function __construct() {
8291 parent::__construct( 'LanguageStats' );
8392
@@ -392,8 +401,12 @@
393402 }
394403 }
395404
396 - if ( !$group instanceof AggregateMessageGroup ) {
397 - $this->totals = MessageGroupStats::multiAdd( $this->totals, $stats );
 405+
 406+ if ( !$group instanceof AggregateMessageGroup ) {
 407+ if ( !isset( $this->statsCounted[$groupId] ) ) {
 408+ $this->totals = MessageGroupStats::multiAdd( $this->totals, $stats );
 409+ $this->statsCounted[$groupId] = true;
 410+ }
398411 }
399412
400413 $rowParams = array();

Status & tagging log