Index: trunk/extensions/Translate/utils/MessageGroupStats.php |
— | — | @@ -176,13 +176,26 @@ |
177 | 177 | return $stats; |
178 | 178 | } |
179 | 179 | |
| 180 | + protected static function expandAggregates( MessageGroup $group ) { |
| 181 | + $flattened = array( $group->getId() ); |
| 182 | + if ( $group instanceof AggregateMessageGroup ) { |
| 183 | + foreach ( $group->getGroups() as $subgroup ) { |
| 184 | + $flattened = array_merge( $flattened, self::expandAggregates( $subgroup ) ); |
| 185 | + } |
| 186 | + } |
| 187 | + return $flattened; |
| 188 | + } |
| 189 | + |
| 190 | + |
| 191 | + |
180 | 192 | protected static function forGroupInternal( $group, $stats = array() ) { |
181 | | - $id = $group->getId(); |
182 | | - $res = self::selectRowsIdLang( $id, null ); |
| 193 | + $ids = array_unique( self::expandAggregates( $group ) ); |
| 194 | + $res = self::selectRowsIdLang( $ids, null ); |
183 | 195 | $stats = self::extractResults( $res, $stats ); |
184 | 196 | |
185 | 197 | # Go over each language filling missing entries |
186 | | - $languages = array_keys( Language::getLanguageNames() ); |
| 198 | + $id = $group->getId(); |
| 199 | + $languages = array_keys( Language::getLanguageNames( false ) ); |
187 | 200 | foreach ( $languages as $code ) { |
188 | 201 | if ( isset( $stats[$id][$code] ) ) continue; |
189 | 202 | $stats[$id][$code] = self::forItemInternal( $stats, $group, $code ); |
— | — | @@ -210,14 +223,9 @@ |
211 | 224 | $id = $group->getId(); |
212 | 225 | |
213 | 226 | if ( self::$timeStart !== null && ( microtime( true ) - self::$timeStart ) > self::$limit ) { |
214 | | - return array( null, null, null ); |
| 227 | + return $stats[$id][$code] = array( null, null, null ); |
215 | 228 | } |
216 | 229 | |
217 | | - // Might happen when called recursively |
218 | | - if ( isset( $stats[$id][$code] ) ) { |
219 | | - return $stats[$id][$code]; |
220 | | - } |
221 | | - |
222 | 230 | if ( $group instanceof AggregateMessageGroup ) { |
223 | 231 | $aggregates = array( 0, 0, 0 ); |
224 | 232 | foreach ( $group->getGroups() as $sid => $sgroup ) { |
— | — | @@ -226,7 +234,7 @@ |
227 | 235 | } |
228 | 236 | $aggregates = self::multiAdd( $aggregates, $stats[$sid][$code] ); |
229 | 237 | } |
230 | | - $stats[$id] = $aggregates; |
| 238 | + $stats[$id][$code] = $aggregates; |
231 | 239 | } else { |
232 | 240 | $aggregates = self::calculateGroup( $group, $code ); |
233 | 241 | } |