r59341 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r59340‎ | r59341 | r59342 >
Date:19:17, 22 November 2009
Author:nikerabbit
Status:ok
Tags:
Comment:
More error handling
Modified paths:
  • /trunk/extensions/Translate/ffs/Gettext.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/ffs/Gettext.php
@@ -264,8 +264,12 @@
265265 $pluralForm = $text;
266266 foreach ( $plurals[0] as $index => $definition ) {
267267 $parsedFormsArray = explode( '|', $plurals[1][$index] );
268 - if ( !isset($parsedFormsArray[$i]) ) throw new MWException( "Too few plural forms in: $text" );
269 - $pluralForm = str_replace( $pluralForm, $definition, $parsedFormsArray[$i] );
 268+ if ( !isset($parsedFormsArray[$i]) ) {
 269+ error_log( "Too few plural forms in: $text" );
 270+ $pluralForm = '';
 271+ } else {
 272+ $pluralForm = str_replace( $pluralForm, $definition, $parsedFormsArray[$i] );
 273+ }
270274 }
271275 $splitPlurals[$i] = $pluralForm;
272276 }
@@ -348,6 +352,8 @@
349353 // Then parse the messages
350354 foreach ( $sections as $section ) {
351355 if ( trim( $section ) === '' ) continue;
 356+ // These inactive section are of no interest to us
 357+ if ( preg_match( '/^#~/', $section ) ) continue;
352358
353359 $item = array(
354360 'ctxt' => '',

Status & tagging log