3require_once __DIR__ .
'/Maintenance.php';
8 'MessagesDirs' =>
'handleMessagesDirs',
9 'ExtensionMessagesFiles' =>
'handleExtensionMessagesFiles',
10 'AutoloadClasses' =>
'removeAbsolutePath',
11 'ExtensionCredits' =>
'handleCredits',
12 'ResourceModules' =>
'handleResourceModules',
13 'ResourceModuleSkinStyles' =>
'handleResourceModules',
14 'Hooks' =>
'handleHooks',
15 'ExtensionFunctions' =>
'handleExtensionFunctions',
16 'ParserTestFiles' =>
'removeAutodiscoveredParserTestFiles',
34 'SpecialPageGroups' =>
'deprecated',
57 parent::__construct();
58 $this->
addDescription(
'Converts extension entry points to the new JSON registration format' );
59 $this->
addArg(
'path',
'Location to the PHP entry point you wish to convert',
61 $this->
addOption(
'skin',
'Whether to write to skin.json',
false,
false );
62 $this->
addOption(
'config-prefix',
'Custom prefix for configuration settings',
false,
true );
67 $settings = $processor->getProperty(
'globalSettings' );
68 $settings->setAccessible(
true );
69 return array_merge( $settings->getValue(), $this->formerGlobals );
78 foreach ( $__settings as $var ) {
96 $configPrefix = $this->
getOption(
'config-prefix',
'wg' );
97 if ( $configPrefix !==
'wg' ) {
101 $realName =
substr( $name, 2 );
102 if ( $realName ===
false ) {
111 if (
isset( $this->custom[$realName] ) ) {
117 $this->
output(
'Warning: Skipped global "' . $name .
'" (' .
118 $this->noLongerSupportedGlobals[$realName] .
'). ' .
119 "Please update the entry point before convert to registration.\n" );
120 $this->hasWarning =
true;
124 }
elseif ( $configPrefix !==
'wg' &&
strpos( $name,
'wg' ) === 0 ) {
126 $this->
output(
'Warning: Skipped global "' . $name .
'" (' .
127 'config prefix is "' . $configPrefix .
'"). ' .
128 "Please check that this setting isn't needed.\n" );
135 $this->
output(
"Detected composer dependencies, setting 'load_composer_autoloader' to true.\n" );
136 $this->
json[
'load_composer_autoloader'] =
true;
141 foreach ( $this->promote as $key ) {
156 $fname =
"{$this->dir}/$type.json";
157 $prettyJSON = FormatJson::encode(
$out,
"\t", FormatJson::ALL_OK );
159 $this->
output(
"Wrote output to $fname.\n" );
160 if ( $this->hasWarning ) {
161 $this->
output(
"Found warnings! Please resolve the warnings and rerun this script.\n" );
166 foreach (
$value as $func ) {
167 if ( $func instanceof Closure ) {
168 $this->
fatalError(
"Error: Closures cannot be converted to JSON. " .
169 "Please move your extension function somewhere else."
174 $this->
fatalError(
"Error: Global functions cannot be converted to JSON. " .
175 "Please move your extension function ($func) into a class."
184 foreach (
$value as $key => $dirs ) {
186 $this->
json[$realName][$key][] = $this->
stripPath( $dir, $this->dir );
192 foreach (
$value as $key => $file ) {
193 $strippedFile = $this->
stripPath( $file, $this->dir );
194 if (
isset(
$vars[
'wgMessagesDirs'][$key] ) ) {
196 "Note: Ignoring PHP shim $strippedFile. " .
197 "If your extension no longer supports versions of MediaWiki " .
198 "older than 1.23.0, you can safely delete it.\n"
207 if ( $val ===
$dir ) {
219 foreach (
$value as $key => $val ) {
227 foreach (
$value as $key => $val ) {
228 $path = $this->
stripPath( $val, $this->dir );
231 if (
substr( $path, 0, 13 ) !==
'tests/parser/' ||
substr( $path, -4 ) !==
'.txt' ) {
245 foreach ( $values[0][0] as $name => $val ) {
246 if ( $name !==
'path' ) {
253 foreach (
$value as $hookName => &$handlers ) {
254 if ( $hookName ===
'UnitTestsList' ) {
255 $this->
output(
"Note: the UnitTestsList hook is no longer necessary as " .
256 "long as your tests are located in the \"tests/phpunit/\" directory. " .
257 "Please see <https://www.mediawiki.org/wiki/Manual:PHP_unit_testing/" .
258 "Writing_unit_tests_for_extensions#Register_your_tests> for more details.\n"
261 foreach ( $handlers as $func ) {
262 if ( $func instanceof Closure ) {
263 $this->
fatalError(
"Error: Closures cannot be converted to JSON. " .
264 "Please move the handler for $hookName somewhere else."
269 $this->
fatalError(
"Error: Global functions cannot be converted to JSON. " .
270 "Please move the handler for $hookName inside a class."
274 if ( count( $handlers ) === 1 ) {
275 $handlers = $handlers[0];
283 $remote = $this->
hasOption(
'skin' ) ?
'remoteSkinPath' :
'remoteExtPath';
288 $defaults[
'localBasePath'] =
$data[
'localBasePath'];
295 if (
$data[
'localBasePath'] === $defaults[
'localBasePath'] ) {
299 &&
$data[$remote] === $defaults[$remote]
309 $this->
json[
'ResourceFileModulePaths'] = $defaults;
314 $path .=
'/composer.json';
319 if ( $composerJson->getRequiredDependencies() ) {
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
if(defined( 'MW_SETUP_CALLBACK')) $fname
Customization point after all loading (constants, functions, classes, DefaultSettings,...
Reads a composer.json file and provides accessors to get its hash and the required dependencies.
handleMessagesDirs( $realName, $value)
string[] $promote
Keys that should be put at the top of the generated JSON file (T86608)
string[] $noLongerSupportedGlobals
No longer supported globals (with reason) should not be converted and emit a warning.
handleResourceModules( $realName, $value)
string[] $formerGlobals
Things that were formerly globals and should still be converted.
handleExtensionFunctions( $realName, $value)
needsComposerAutoloader( $path)
handleHooks( $realName, $value)
handleExtensionMessagesFiles( $realName, $value, $vars)
removeAutodiscoveredParserTestFiles( $realName, $value)
removeAbsolutePath( $realName, $value)
execute()
Do the actual work.
__construct()
Default constructor.
handleCredits( $realName, $value)
const MANIFEST_VERSION
Version of the highest supported manifest version Note: Update MANIFEST_VERSION_MW_VERSION when chang...
const MANIFEST_VERSION_MW_VERSION
MediaWiki version constraint representing what the current highest MANIFEST_VERSION is supported in.
const MEDIAWIKI_CORE
"requires" key that applies to MediaWiki core/$wgVersion
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
addArg( $arg, $description, $required=true)
Add some args that are needed.
output( $out, $channel=null)
Throw some output to the user.
hasOption( $name)
Checks to see if a particular option exists.
getArg( $argId=0, $default=null)
Get an argument.
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.
static configuration should be added through ResourceLoaderGetConfigVars instead & $vars
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
Allows to change the fields on the form that will be generated $name
$data
Utility to generate mapping file used in mw.Title (phpCharToUpper.json)
require_once RUN_MAINTENANCE_IF_MAIN
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))