r99577 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99576‎ | r99577 | r99578 >
Date:21:34, 11 October 2011
Author:reedy
Status:ok
Tags:
Comment:
Bit more refactoring
Modified paths:
  • /trunk/phase3/maintenance/mergeMessageFileList.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/mergeMessageFileList.php
@@ -26,8 +26,7 @@
2727 define( 'MW_NO_EXTENSION_MESSAGES', 1 );
2828
2929 require_once( dirname( __FILE__ ) . '/Maintenance.php' );
30 -$maintClass = 'MergeMessageFileList';
31 -$mmfl = false;
 30+
3231 class MergeMessageFileList extends Maintenance {
3332
3433 function __construct() {
@@ -39,8 +38,6 @@
4039 }
4140
4241 public function execute() {
43 - global $mmfl;
44 -
4542 $lines = file( $this->getOption( 'list-file' ) );
4643 if ( $lines === false ) {
4744 $this->error( 'Unable to open list file.' );
@@ -49,43 +46,44 @@
5047 if ( $this->hasOption( 'output' ) ) {
5148 $mmfl['output'] = $this->getOption( 'output' );
5249 }
53 - }
54 -}
5550
56 -require_once( RUN_MAINTENANCE_IF_MAIN );
 51+ global $IP, $wgExtensionMessagesFiles, $wgExtensionAliasesFiles;
 52+ foreach ( $mmfl['setupFiles'] as $fileName ) {
 53+ if ( strval( $fileName ) === '' ) {
 54+ continue;
 55+ }
 56+ $fileName = str_replace( '$IP', $IP, $fileName );
 57+ fwrite( STDERR, "Loading data from $fileName\n" );
 58+ include_once( $fileName );
 59+ }
 60+ fwrite( STDERR, "\n" );
 61+ $s =
 62+ "<" . "?php\n" .
 63+ "## This file is generated by mergeMessageFileList.php. Do not edit it directly.\n\n" .
 64+ "if ( defined( 'MW_NO_EXTENSION_MESSAGES' ) ) return;\n\n" .
 65+ '$wgExtensionMessagesFiles = ' . var_export( $wgExtensionMessagesFiles, true ) . ";\n\n" .
 66+ '$wgExtensionAliasesFiles = ' . var_export( $wgExtensionAliasesFiles, true ) . ";\n";
5767
58 -foreach ( $mmfl['setupFiles'] as $fileName ) {
59 - if ( strval( $fileName ) === '' ) {
60 - continue;
61 - }
62 - $fileName = str_replace( '$IP', $IP, $fileName );
63 - fwrite( STDERR, "Loading data from $fileName\n" );
64 - include_once( $fileName );
65 -}
66 -fwrite( STDERR, "\n" );
67 -$s =
68 - "<" . "?php\n" .
69 - "## This file is generated by mergeMessageFileList.php. Do not edit it directly.\n\n" .
70 - "if ( defined( 'MW_NO_EXTENSION_MESSAGES' ) ) return;\n\n" .
71 - '$wgExtensionMessagesFiles = ' . var_export( $wgExtensionMessagesFiles, true ) . ";\n\n" .
72 - '$wgExtensionAliasesFiles = ' . var_export( $wgExtensionAliasesFiles, true ) . ";\n";
 68+ $dirs = array(
 69+ $IP,
 70+ dirname( dirname( __FILE__ ) ),
 71+ realpath( $IP )
 72+ );
7373
74 -$dirs = array(
75 - $IP,
76 - dirname( dirname( __FILE__ ) ),
77 - realpath( $IP )
78 -);
 74+ foreach ( $dirs as $dir ) {
 75+ $s = preg_replace(
 76+ "/'" . preg_quote( $dir, '/' ) . "([^']*)'/",
 77+ '"$IP\1"',
 78+ $s );
 79+ }
7980
80 -foreach ( $dirs as $dir ) {
81 - $s = preg_replace(
82 - "/'" . preg_quote( $dir, '/' ) . "([^']*)'/",
83 - '"$IP\1"',
84 - $s );
 81+ if ( isset( $mmfl['output'] ) ) {
 82+ file_put_contents( $mmfl['output'], $s );
 83+ } else {
 84+ echo $s;
 85+ }
 86+ }
8587 }
8688
87 -if ( isset( $mmfl['output'] ) ) {
88 - file_put_contents( $mmfl['output'], $s );
89 -} else {
90 - echo $s;
91 -}
92 -
 89+$maintClass = 'MergeMessageFileList';
 90+require_once( RUN_MAINTENANCE_IF_MAIN );

Status & tagging log