# Start from scratch
define( 'MW_NO_EXTENSION_MESSAGES', 1 );
-require_once( __DIR__ . '/Maintenance.php' );
+require_once __DIR__ . '/Maintenance.php';
$maintClass = 'MergeMessageFileList';
$mmfl = false;
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;
if ( $this->hasOption( 'extensions-dir' ) ) {
$extdir = $this->getOption( 'extensions-dir' );
$entries = scandir( $extdir );
- foreach( $entries as $extname ) {
+ foreach ( $entries as $extname ) {
if ( $extname == '.' || $extname == '..' || !is_dir( "$extdir/$extname" ) ) {
continue;
}
if ( $this->hasOption( 'output' ) ) {
$mmfl['output'] = $this->getOption( 'output' );
}
+ if ( $this->hasOption( 'quiet' ) ) {
+ $mmfl['quiet'] = true;
+ }
}
}
-require_once( RUN_MAINTENANCE_IF_MAIN );
+require_once RUN_MAINTENANCE_IF_MAIN;
foreach ( $mmfl['setupFiles'] as $fileName ) {
if ( strval( $fileName ) === '' ) {
continue;
}
$fileName = str_replace( '$IP', $IP, $fileName );
- fwrite( STDERR, "Loading data from $fileName\n" );
- include_once( $fileName );
+ if ( empty( $mmfl['quiet'] ) ) {
+ fwrite( STDERR, "Loading data from $fileName\n" );
+ }
+ if ( !( include_once $fileName ) ) {
+ fwrite( STDERR, "Unable to read $fileName\n" );
+ exit( 1 );
+ }
}
fwrite( STDERR, "\n" );
$s =
} else {
echo $s;
}
-