registration: When converting, place 'namemsg' under 'name'
[lhc/web/wiklou.git] / maintenance / convertExtensionToRegistration.php
index 8adae2d..608605c 100644 (file)
@@ -31,7 +31,7 @@ class ConvertExtensionToRegistration extends Maintenance {
         * @var array
         */
        protected $noLongerSupportedGlobals = array(
-               'SpecialPageGroups' => 'deprecated',
+               'SpecialPageGroups' => 'deprecated', // Deprecated 1.21, removed in 1.26
        );
 
        /**
@@ -41,12 +41,12 @@ class ConvertExtensionToRegistration extends Maintenance {
         */
        protected $promote = array(
                'name',
+               'namemsg',
                'version',
                'author',
                'url',
                'description',
                'descriptionmsg',
-               'namemsg',
                'license-name',
                'type',
        );
@@ -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 );
        }
 
@@ -78,7 +79,12 @@ class ConvertExtensionToRegistration extends Maintenance {
                        $$var = array();
                }
                unset( $var );
-               require $this->getArg( 0 );
+               $arg = $this->getArg( 0 );
+               if ( !is_file( $arg ) ) {
+                       $this->error( "$arg is not a file.", true );
+               }
+               require $arg;
+               unset( $arg );
                // Try not to create any local variables before this line
                $vars = get_defined_vars();
                unset( $vars['this'] );
@@ -95,7 +101,8 @@ class ConvertExtensionToRegistration extends Maintenance {
                        }
 
                        if ( isset( $this->custom[$realName] ) ) {
-                               call_user_func_array( array( $this, $this->custom[$realName] ), array( $realName, $value, $vars ) );
+                               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 ) ) {
@@ -133,7 +140,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
+                               );
                        }
                }
 
@@ -182,7 +191,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 );
@@ -197,7 +206,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
+                                       );
                                }
                        }
                }
@@ -229,7 +240,6 @@ class ConvertExtensionToRegistration extends Maintenance {
                                }
                        }
 
-
                        $this->json[$realName][$name] = $data;
                }
                if ( $defaults ) {