r106194 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r106193‎ | r106194 | r106195 >
Date:14:01, 14 December 2011
Author:catrope
Status:resolved
Tags:
Comment:
Log failures to read or parse message files
Modified paths:
  • /trunk/extensions/LocalisationUpdate/LocalisationUpdate.class.php (modified) (history)

Diff [purge]

Index: trunk/extensions/LocalisationUpdate/LocalisationUpdate.class.php
@@ -326,7 +326,8 @@
327327 $basefilecontents = self::getFileContents( $basefile );
328328
329329 if ( $basefilecontents === false || $basefilecontents === '' ) {
330 - return array(); // Failed
 330+ self::myLog( "Failed to read $basefile" );
 331+ return array();
331332 }
332333
333334 // Only get the part we need.
@@ -346,11 +347,17 @@
347348
348349 // Get the array with messages.
349350 $base_messages = self::parsePHP( $basefilecontents, 'base_messages' );
 351+ if ( !is_array( $base_messages ) ) {
 352+ // Broken file? Report and bail
 353+ self::myLog( "Failed to parse $basefile" );
 354+ return array();
 355+ }
350356
351357 $comparefilecontents = self::getFileContents( $comparefile );
352358
353359 if ( $comparefilecontents === false || $comparefilecontents === '' ) {
354 - return array(); // Failed
 360+ self::myLog( "Failed to read $comparefile" );
 361+ return array();
355362 }
356363
357364 // Only get the stuff we need.
@@ -370,6 +377,11 @@
371378
372379 // Get the array.
373380 $compare_messages = self::parsePHP( $comparefilecontents, 'compare_messages' );
 381+ if ( !is_array( $compare_messages ) ) {
 382+ // Broken file? Report and bail
 383+ self::myLog( "Failed to parse $comparefile" );
 384+ return array();
 385+ }
374386
375387 // If the localfile and the remote file are the same, skip them!
376388 if ( $basehash == $comparehash && !$alwaysGetResult ) {

Follow-up revisions

RevisionCommit summaryAuthorDate
r1061961.18wmf1: MFT r106194catrope14:03, 14 December 2011
r106199Followup r106194: some files deliberately don't have a $messages array becaus...catrope14:27, 14 December 2011

Status & tagging log