summaryrefslogtreecommitdiff
path: root/maintenance/convertExtensionToRegistration.php
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2016-05-01 15:32:59 -0400
committerLuke Shumaker <lukeshu@sbcglobal.net>2016-05-01 15:32:59 -0400
commit6dc1997577fab2c366781fd7048144935afa0012 (patch)
tree8918d28c7ab4342f0738985e37af1dfc42d0e93a /maintenance/convertExtensionToRegistration.php
parent150f94f051128f367bc89f6b7e5f57eb2a69fc62 (diff)
parentfa89acd685cb09cdbe1c64cbb721ec64975bbbc1 (diff)
Merge commit 'fa89acd'
# Conflicts: # .gitignore # extensions/ArchInterWiki.sql
Diffstat (limited to 'maintenance/convertExtensionToRegistration.php')
-rw-r--r--maintenance/convertExtensionToRegistration.php39
1 files changed, 30 insertions, 9 deletions
diff --git a/maintenance/convertExtensionToRegistration.php b/maintenance/convertExtensionToRegistration.php
index acb8d3aa..3e86d8a6 100644
--- a/maintenance/convertExtensionToRegistration.php
+++ b/maintenance/convertExtensionToRegistration.php
@@ -6,7 +6,7 @@ class ConvertExtensionToRegistration extends Maintenance {
protected $custom = array(
'MessagesDirs' => 'handleMessagesDirs',
- 'ExtensionMessagesFiles' => 'removeAbsolutePath',
+ 'ExtensionMessagesFiles' => 'handleExtensionMessagesFiles',
'AutoloadClasses' => 'removeAbsolutePath',
'ExtensionCredits' => 'handleCredits',
'ResourceModules' => 'handleResourceModules',
@@ -31,7 +31,7 @@ class ConvertExtensionToRegistration extends Maintenance {
* @var array
*/
protected $noLongerSupportedGlobals = array(
- 'SpecialPageGroups' => 'deprecated',
+ 'SpecialPageGroups' => 'deprecated', // Deprecated 1.21, removed in 1.26
);
/**
@@ -56,7 +56,8 @@ class ConvertExtensionToRegistration extends Maintenance {
public function __construct() {
parent::__construct();
$this->mDescription = 'Converts extension entry points to the new JSON registration format';
- $this->addArg( 'path', 'Location to the PHP entry point you wish to convert', /* $required = */ true );
+ $this->addArg( 'path', 'Location to the PHP entry point you wish to convert',
+ /* $required = */ true );
$this->addOption( 'skin', 'Whether to write to skin.json', false, false );
}
@@ -95,7 +96,8 @@ class ConvertExtensionToRegistration extends Maintenance {
}
if ( isset( $this->custom[$realName] ) ) {
- call_user_func_array( array( $this, $this->custom[$realName] ), array( $realName, $value ) );
+ call_user_func_array( array( $this, $this->custom[$realName] ),
+ array( $realName, $value, $vars ) );
} elseif ( in_array( $realName, $globalSettings ) ) {
$this->json[$realName] = $value;
} elseif ( array_key_exists( $realName, $this->noLongerSupportedGlobals ) ) {
@@ -118,7 +120,8 @@ class ConvertExtensionToRegistration extends Maintenance {
}
}
$out += $this->json;
-
+ // Put this at the bottom
+ $out['manifest_version'] = ExtensionRegistry::MANIFEST_VERSION;
$type = $this->hasOption( 'skin' ) ? 'skin' : 'extension';
$fname = "{$this->dir}/$type.json";
$prettyJSON = FormatJson::encode( $out, "\t", FormatJson::ALL_OK );
@@ -132,7 +135,9 @@ class ConvertExtensionToRegistration extends Maintenance {
protected function handleExtensionFunctions( $realName, $value ) {
foreach ( $value as $func ) {
if ( $func instanceof Closure ) {
- $this->error( "Error: Closures cannot be converted to JSON. Please move your extension function somewhere else.", 1 );
+ $this->error( "Error: Closures cannot be converted to JSON. " .
+ "Please move your extension function somewhere else.", 1
+ );
}
}
@@ -147,6 +152,21 @@ class ConvertExtensionToRegistration extends Maintenance {
}
}
+ protected function handleExtensionMessagesFiles( $realName, $value, $vars ) {
+ foreach ( $value as $key => $file ) {
+ $strippedFile = $this->stripPath( $file, $this->dir );
+ if ( isset( $vars['wgMessagesDirs'][$key] ) ) {
+ $this->output(
+ "Note: Ignoring PHP shim $strippedFile. " .
+ "If your extension no longer supports versions of MediaWiki " .
+ "older than 1.23.0, you can safely delete it.\n"
+ );
+ } else {
+ $this->json[$realName][$key] = $strippedFile;
+ }
+ }
+ }
+
private function stripPath( $val, $dir ) {
if ( $val === $dir ) {
$val = '';
@@ -166,7 +186,7 @@ class ConvertExtensionToRegistration extends Maintenance {
$this->json[$realName] = $out;
}
- protected function handleCredits( $realName, $value) {
+ protected function handleCredits( $realName, $value ) {
$keys = array_keys( $value );
$this->json['type'] = $keys[0];
$values = array_values( $value );
@@ -181,7 +201,9 @@ class ConvertExtensionToRegistration extends Maintenance {
foreach ( $value as $hookName => $handlers ) {
foreach ( $handlers as $func ) {
if ( $func instanceof Closure ) {
- $this->error( "Error: Closures cannot be converted to JSON. Please move the handler for $hookName somewhere else.", 1 );
+ $this->error( "Error: Closures cannot be converted to JSON. " .
+ "Please move the handler for $hookName somewhere else.", 1
+ );
}
}
}
@@ -213,7 +235,6 @@ class ConvertExtensionToRegistration extends Maintenance {
}
}
-
$this->json[$realName][$name] = $data;
}
if ( $defaults ) {