Discard comments in mergeMessageFileList.php's --list-file file
authorOri Livneh <ori@wikimedia.org>
Thu, 18 Jul 2013 22:46:18 +0000 (15:46 -0700)
committerOri Livneh <ori@wikimedia.org>
Wed, 24 Jul 2013 04:58:30 +0000 (21:58 -0700)
We're currently working around a bug in an extension (bug 51643) by deviating
from lexicographical order in extension-list to ensure that one extension is
loaded before another. It'd be nice to be able to document that in the file
itself, but there is no convention for adding comments to the file;
mergeMessageFileList.php treats every line as a file name. We've previously
talked about including a comment header in the file as part of our reponse to
bug 50347.

This patch adds some minimal syntax-handling to mergeMessageFileList.php which
causes it to treat as a comment any substring starting with '#' and extending
to the end of the line. This change implements part of what aude projected for
Gerrit change 71056, but I don't see the harm in pushing ahead with it here.

Change-Id: I4b296aa69ad77ecb51f1a0e27ce6a698cf09732b

maintenance/mergeMessageFileList.php

index 2b680d3..b36a319 100644 (file)
@@ -54,7 +54,16 @@ class MergeMessageFileList extends Maintenance {
                if ( $lines === false ) {
                        $this->error( 'Unable to open list file.' );
                }
-               $mmfl = array( 'setupFiles' => array_map( 'trim', $lines ) );
+               $mmfl = array( 'setupFiles' => array() );
+
+               # Strip comments, discard empty lines, and trim leading and trailing
+               # whitespace. Comments start with '#' and extend to the end of the line.
+               foreach( $lines as $line ) {
+                       $line = trim( preg_replace( '/#.*/', '', $line ) );
+                       if ( $line !== '' ) {
+                               $mmfl['setupFiles'][] = $line;
+                       }
+               }
 
                # Now find out files in a directory
                $hasError = false;