Index: trunk/phase3/maintenance/mergeMessageFileList.php |
— | — | @@ -2,23 +2,18 @@ |
3 | 3 | |
4 | 4 | require_once( dirname( __FILE__ ).'/Maintenance.php' ); |
5 | 5 | $maintClass = 'MergeMessageFileList'; |
6 | | - |
| 6 | +$mmfl = false; |
7 | 7 | class MergeMessageFileList extends Maintenance { |
8 | 8 | |
9 | 9 | function __construct() { |
10 | | - $this->addOption( 'list-file', 'A file containing a list of wikis, one per line.', false, true ); |
11 | | - $this->addOption( 'get', 'Get the message files for a single wiki (for internal use).' ); |
| 10 | + $this->addOption( 'list-file', 'A file containing a list of extension setup files, one per line.', false, true ); |
12 | 11 | $this->addOption( 'output', 'Send output to this file (omit for stdout)', false, true ); |
13 | | - $this->mDescription = 'Merge $wgExtensionMessagesFiles from various wikis to produce a ' . |
| 12 | + $this->mDescription = 'Merge $wgExtensionMessagesFiles from various extensions to produce a ' . |
14 | 13 | 'single array containing all message files.'; |
15 | 14 | } |
16 | 15 | |
17 | 16 | public function execute() { |
18 | | - if ( $this->hasOption( 'get' ) ) { |
19 | | - var_export( $GLOBALS['wgExtensionMessagesFiles'] ); |
20 | | - return; |
21 | | - } |
22 | | - |
| 17 | + global $IP, $mmfl; |
23 | 18 | if ( !$this->hasOption( 'list-file' ) ) { |
24 | 19 | $this->error( 'The --list-file option must be specified.' ); |
25 | 20 | return; |
— | — | @@ -28,32 +23,31 @@ |
29 | 24 | if ( $lines === false ) { |
30 | 25 | $this->error( 'Unable to open list file.' ); |
31 | 26 | } |
32 | | - $wikis = array_map( 'trim', $lines ); |
33 | | - |
34 | | - # Find PHP |
35 | | - $php = readlink( '/proc/' . posix_getpid() . '/exe' ); |
36 | | - $allFiles = array(); |
37 | | - |
38 | | - foreach ( $wikis as $wiki ) { |
39 | | - $s = wfShellExec( wfEscapeShellArg( $php, __FILE__, '--get', |
40 | | - '--wiki', $wiki ) ); |
41 | | - if ( !$s ) { |
42 | | - $this->error( 'Unable to get messages for wiki '. $wiki ); |
43 | | - continue; |
44 | | - } |
45 | | - $files = eval( "return $s;" ); |
46 | | - $allFiles += $files; |
47 | | - } |
48 | | - $s = '$wgExtensionMessagesFiles = ' . |
49 | | - var_export( $allFiles, true ) . |
50 | | - ";\n"; |
| 27 | + $mmfl = array( 'setupFiles' => array_map( 'trim', $lines ) ); |
51 | 28 | if ( $this->hasOption( 'output' ) ) { |
52 | | - file_put_contents( $this->getOption( 'output' ), $s ); |
53 | | - } else { |
54 | | - echo $s; |
| 29 | + $mmfl['output'] = $this->getOption( 'output' ); |
55 | 30 | } |
56 | 31 | } |
57 | 32 | } |
58 | 33 | |
59 | 34 | require_once( DO_MAINTENANCE ); |
60 | 35 | |
| 36 | +foreach ( $mmfl['setupFiles'] as $fileName ) { |
| 37 | + if ( strval( $fileName ) === '' ) { |
| 38 | + continue; |
| 39 | + } |
| 40 | + $fileName = str_replace( '$IP', $IP, $fileName ); |
| 41 | + include_once( $fileName ); |
| 42 | +} |
| 43 | +fwrite( STDERR, "\n" ); |
| 44 | +$s = '$wgExtensionMessagesFiles = ' . var_export( $wgExtensionMessagesFiles, true ) . ";\n\n" . |
| 45 | + '$wgExtensionAliasesFiles = ' . var_export( $wgExtensionAliasesFiles, true ) . ";\n"; |
| 46 | + |
| 47 | +$s = preg_replace( "/'" . preg_quote( $IP, '/' ) . "([^']*)'/", |
| 48 | + '"$IP/\1"', $s ); |
| 49 | +if ( isset( $mmfl['output'] ) ) { |
| 50 | + file_put_contents( $mmfl['output'], $s ); |
| 51 | +} else { |
| 52 | + echo $s; |
| 53 | +} |
| 54 | + |