https://www.mediawiki.org/wiki/Special:Code/MediaWiki/114371

Revision: 114371
Author:   nikerabbit
Date:     2012-03-21 14:23:25 +0000 (Wed, 21 Mar 2012)
Log Message:
-----------
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: trunk/extensions/Translate/specials/SpecialLanguageStats.php
===================================================================
--- trunk/extensions/Translate/specials/SpecialLanguageStats.php        
2012-03-21 14:02:24 UTC (rev 114370)
+++ trunk/extensions/Translate/specials/SpecialLanguageStats.php        
2012-03-21 14:23:25 UTC (rev 114371)
@@ -77,6 +77,15 @@
         */
        protected $purge;
 
+       /**
+        * Helper variable to avoid overcounting message groups that appear
+        * multiple times in the list with different parents. Aggregate message
+        * group stats are always excluded from totals.
+        *
+        * @var array
+        */
+       protected $statsCounted = array();
+
        public function __construct() {
                parent::__construct( 'LanguageStats' );
 
@@ -392,8 +401,12 @@
                        }
                }
 
-               if ( !$group instanceof AggregateMessageGroup ) {
-                       $this->totals = MessageGroupStats::multiAdd( 
$this->totals, $stats );
+               
+               if ( !$group instanceof AggregateMessageGroup  ) {
+                       if ( !isset( $this->statsCounted[$groupId] ) ) {
+                               $this->totals = MessageGroupStats::multiAdd( 
$this->totals, $stats );
+                               $this->statsCounted[$groupId] = true;
+                       }
                }
 
                $rowParams = array();


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to