r111456 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111455‎ | r111456 | r111457 >
Date:12:45, 14 February 2012
Author:siebrand
Status:resolved (Comments)
Tags:i18nreview 
Comment:
* update documentation.
* add skipMeta parameter to MessageGroup::getGroupsById() to all filtering out aggregate groups.
* update export.php to use skipMeta to avoid fatal error.
Modified paths:
  • /trunk/extensions/Translate/MessageGroups.php (modified) (history)
  • /trunk/extensions/Translate/scripts/export.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/scripts/export.php
@@ -98,8 +98,9 @@
9999 if ( isset( $options['group'] ) ) {
100100 $groupIds = explode( ',', trim( $options['group'] ) );
101101 }
 102+
102103 $groupIds = MessageGroups::expandWildcards( $groupIds );
103 -$groups = MessageGroups::getGroupsById( $groupIds );
 104+$groups = MessageGroups::getGroupsById( $groupIds, true );
104105
105106 if ( !count( $groups ) ) {
106107 STDERR( "EE1: No valid message groups identified." );
Index: trunk/extensions/Translate/MessageGroups.php
@@ -1319,18 +1319,22 @@
13201320 /**
13211321 * Get message groups for corresponding message group ids.
13221322 *
1323 - * @param $groups array Group IDs
1324 - * @param $groupPrefix string Prefix for groups
 1323+ * @param $ids array Group IDs
 1324+ * @param $skipMeta bool Skip aggregate message groups
13251325 * @return array
13261326 * @since 2012-02-13
13271327 */
1328 - public static function getGroupsById( array $ids ) {
 1328+ public static function getGroupsById( array $ids, $skipMeta = false ) {
13291329 $groups = array();
13301330 foreach ( $ids as $id ) {
13311331 $group = self::getGroup( $id );
13321332
13331333 if ( $group !== null ) {
1334 - $groups[$id] = $group;
 1334+ if( $group->isMeta() && $skipMeta ) {
 1335+ continue;
 1336+ } else {
 1337+ $groups[$id] = $group;
 1338+ }
13351339 } else {
13361340 wfDebug( __METHOD__ . ": Invalid message group id: $id\n" );
13371341 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r111457Follow-up r111456: Cheaper check first.siebrand12:54, 14 February 2012
r112787Followup r111456. Move the complexity to caller and keep other code "clean".nikerabbit10:33, 1 March 2012

Comments

#Comment by Nikerabbit (talk | contribs)   17:55, 14 February 2012

Can't the caller do this? Boolean parameters in functions calls are bad for readability.

Status & tagging log