26define(
'MW_NO_EXTENSION_MESSAGES', 1 );
28require_once __DIR__ .
'/Maintenance.php';
40 parent::__construct();
43 'A file containing a list of extension setup files, one per line.',
47 $this->
addOption(
'extensions-dir',
'Path where extensions can be found.',
false,
true );
48 $this->
addOption(
'output',
'Send output to this file (omit for stdout)',
false,
true );
49 $this->
addDescription(
'Merge $wgExtensionMessagesFiles and $wgMessagesDirs from ' .
50 ' various extensions to produce a single file listing all message files and dirs.'
63 $this->
fatalError(
"Either --list-file or --extensions-dir must be provided if " .
64 "\$wgExtensionEntryPointListFiles is not set" );
67 $mmfl = [
'setupFiles' => [] ];
69 # Add setup files contained in file passed to --list-file
72 $mmfl[
'setupFiles'] = array_merge(
$mmfl[
'setupFiles'], $extensionPaths );
75 # Now find out files in a directory
76 if ( $this->
hasOption(
'extensions-dir' ) ) {
77 $extdir = $this->
getOption(
'extensions-dir' );
78 # Allow multiple directories to be passed with ":" as delimiter
79 $extdirs = explode(
':', $extdir );
81 foreach ( $extdirs as $extdir ) {
82 $entries = scandir( $extdir );
83 foreach ( $entries as $extname ) {
84 if ( $extname ==
'.' || $extname ==
'..' || !is_dir(
"$extdir/$extname" ) ) {
88 "$extdir/$extname/extension.json",
89 "$extdir/$extname/skin.json",
90 "$extdir/$extname/$extname.php"
93 foreach ( $possibilities as $extfile ) {
94 if ( file_exists( $extfile ) ) {
95 $mmfl[
'setupFiles'][] = $extfile;
102 $this->
error(
"Extension {$extname} in {$extdir} lacks expected entry point: " .
103 "extension.json, skin.json, or {$extname}.php." );
109 # Add setup files defined via configuration
110 foreach ( $wgExtensionEntryPointListFiles as
$points ) {
111 $extensionPaths = $this->
readFile( $points );
112 $mmfl[
'setupFiles'] = array_merge(
$mmfl[
'setupFiles'], $extensionPaths );
116 $mmfl[
'output'] = $this->
getOption(
'output' );
119 $mmfl[
'quiet'] =
true;
131 $fileLines =
file( $fileName );
132 if ( $fileLines ===
false ) {
133 $this->hasError =
true;
134 $this->
error(
"Unable to open list file $fileName." );
138 # Strip comments, discard empty lines, and trim leading and trailing
139 # whitespace. Comments start with '#' and extend to the end of the line.
140 foreach ( $fileLines as $extension ) {
141 $extension = trim( preg_replace(
'/#.*/',
'', $extension ) );
142 if ( $extension !==
'' ) {
143 # Paths may use the string $IP to be substituted by the actual value
144 $extension = str_replace(
'$IP',
$IP, $extension );
145 if ( file_exists( $extension ) ) {
146 $files[] = $extension;
148 $this->hasError =
true;
149 $this->
error(
"Extension {$extension} doesn't exist" );
161foreach (
$mmfl[
'setupFiles'] as $fileName ) {
162 if ( strval( $fileName ) ===
'' ) {
165 if ( empty(
$mmfl[
'quiet'] ) ) {
166 fwrite( STDERR,
"Loading data from $fileName\n" );
169 if ( substr( $fileName, -strlen(
'.json' ) ) ===
'.json' ) {
172 require_once $fileName;
178 $data = $registry->readFromQueue(
$queue );
179 foreach ( [
'wgExtensionMessagesFiles',
'wgMessagesDirs' ] as $var ) {
180 if ( isset( $data[
'globals'][$var] ) ) {
186fwrite( STDERR,
"\n" );
189 "## This file is generated by mergeMessageFileList.php. Do not edit it directly.\n\n" .
190 "if ( defined( 'MW_NO_EXTENSION_MESSAGES' ) ) return;\n\n" .
200foreach (
$dirs as $dir ) {
201 $s = preg_replace(
"/'" . preg_quote( $dir,
'/' ) .
"([^']*)'/",
'"$IP\1"',
$s );
204if ( isset(
$mmfl[
'output'] ) ) {
205 file_put_contents(
$mmfl[
'output'],
$s );
$wgExtensionEntryPointListFiles
Array of files with list(s) of extension entry points to be used in maintenance/mergeMessageFileList....
$wgMessagesDirs['ReplaceText']
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
hasOption( $name)
Checks to see if a particular param exists.
addDescription( $text)
Set the description text.
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
getOption( $name, $default=null)
Get an option, or return the default.
fatalError( $msg, $exitCode=1)
Output a message and terminate the current script.
Maintenance script that merges $wgExtensionMessagesFiles from various extensions to produce a single ...
execute()
Do the actual work.
__construct()
Default constructor.
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults error
We ve cleaned up the code here by removing clumps of infrequently used code and moving them off somewhere else It s much easier for someone working with this code to see what s _really_ going and make changes or fix bugs In we can take all the code that deals with the little used title reversing we can concentrate it all in an extension file
$wgExtensionMessagesFiles['ExtensionNameMagic']
require_once RUN_MAINTENANCE_IF_MAIN