From 307d27e6e8a2201d139b681b1ae3a9862c1bc979 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Fri, 18 Sep 2009 03:34:34 +0000 Subject: [PATCH] Script to produce a merged $wgExtensionMessagesFiles for the case where a wiki farm uses different messages for different wikis. --- maintenance/mergeMessageFileList.php | 59 ++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 maintenance/mergeMessageFileList.php diff --git a/maintenance/mergeMessageFileList.php b/maintenance/mergeMessageFileList.php new file mode 100644 index 0000000000..8e8de1e15a --- /dev/null +++ b/maintenance/mergeMessageFileList.php @@ -0,0 +1,59 @@ +addOption( 'list-file', 'A file containing a list of wikis, one per line.', false, true ); + $this->addOption( 'get', 'Get the message files for a single wiki (for internal use).' ); + $this->addOption( 'output', 'Send output to this file (omit for stdout)', false, true ); + $this->mDescription = 'Merge $wgExtensionMessagesFiles from various wikis to produce a ' . + 'single array containing all message files.'; + } + + public function execute() { + if ( $this->hasOption( 'get' ) ) { + var_export( $GLOBALS['wgExtensionMessagesFiles'] ); + return; + } + + if ( !$this->hasOption( 'list-file' ) ) { + $this->error( 'The --list-file option must be specified.' ); + return; + } + + $lines = file( $this->getOption( 'list-file' ) ); + if ( $lines === false ) { + $this->error( 'Unable to open list file.' ); + } + $wikis = array_map( 'trim', $lines ); + + # Find PHP + $php = readlink( '/proc/' . posix_getpid() . '/exe' ); + $allFiles = array(); + + foreach ( $wikis as $wiki ) { + $s = wfShellExec( wfEscapeShellArg( $php, __FILE__, '--get', + '--wiki', $wiki ) ); + if ( !$s ) { + $this->error( 'Unable to get messages for wiki '. $wiki ); + continue; + } + $files = eval( "return $s;" ); + $allFiles += $files; + } + $s = '$wgExtensionMessagesFiles = ' . + var_export( $allFiles, true ) . + ";\n"; + if ( $this->hasOption( 'output' ) ) { + file_put_contents( $this->getOption( 'output' ), $s ); + } else { + echo $s; + } + } +} + +require_once( DO_MAINTENANCE ); + -- 2.20.1