OOUIHTMLForm: Correctly handle submit modifier flags
[lhc/web/wiklou.git] / includes / registration / ExtensionProcessor.php
index 4b9a754..273e9ef 100644 (file)
@@ -29,7 +29,6 @@ class ExtensionProcessor implements Processor {
                'ExtensionFunctions',
                'ExtensionEntryPointListFiles',
                'SpecialPages',
-               'SpecialPageGroups',
                'JobClasses',
                'LogTypes',
                'LogRestrictions',
@@ -63,6 +62,28 @@ class ExtensionProcessor implements Processor {
                'license-name',
        );
 
+       /**
+        * Things that are not 'attributes', but are not in
+        * $globalSettings or $creditsAttributes.
+        *
+        * @var array
+        */
+       protected static $notAttributes = array(
+               'callback',
+               'Hooks',
+               'namespaces',
+               'ResourceFileModulePaths',
+               'ResourceModules',
+               'ResourceModuleSkinStyles',
+               'ExtensionMessagesFiles',
+               'MessagesDirs',
+               'type',
+               'config',
+               'ParserTestFiles',
+               'AutoloadClasses',
+               'manifest_version',
+       );
+
        /**
         * Stuff that is going to be set to $GLOBALS
         *
@@ -102,19 +123,13 @@ class ExtensionProcessor implements Processor {
         */
        protected $attributes = array();
 
-       /**
-        * List of keys that have already been processed
-        *
-        * @var array
-        */
-       protected $processed = array();
-
        /**
         * @param string $path
         * @param array $info
+        * @param int $version manifest_version for info
         * @return array
         */
-       public function extractInfo( $path, array $info ) {
+       public function extractInfo( $path, array $info, $version ) {
                $this->extractConfig( $info );
                $this->extractHooks( $info );
                $dir = dirname( $path );
@@ -125,7 +140,6 @@ class ExtensionProcessor implements Processor {
                $this->extractParserTestFiles( $dir, $info );
                if ( isset( $info['callback'] ) ) {
                        $this->callbacks[] = $info['callback'];
-                       $this->processed[] = 'callback';
                }
 
                $this->extractCredits( $path, $info );
@@ -133,11 +147,12 @@ class ExtensionProcessor implements Processor {
                        if ( in_array( $key, self::$globalSettings ) ) {
                                $this->storeToArray( "wg$key", $val, $this->globals );
                        // Ignore anything that starts with a @
-                       } elseif ( $key[0] !== '@' && !in_array( $key, $this->processed ) ) {
+                       } elseif ( $key[0] !== '@' && !in_array( $key, self::$notAttributes )
+                               && !in_array( $key, self::$creditsAttributes )
+                       ) {
                                $this->storeToArray( $key, $val, $this->attributes );
                        }
                }
-
        }
 
        public function getExtractedInfo() {
@@ -152,10 +167,11 @@ class ExtensionProcessor implements Processor {
 
        protected function extractHooks( array $info ) {
                if ( isset( $info['Hooks'] ) ) {
-                       foreach ( $info['Hooks'] as $name => $callable ) {
-                               $this->globals['wgHooks'][$name][] = $callable;
+                       foreach ( $info['Hooks'] as $name => $value ) {
+                               foreach ( (array)$value as $callback ) {
+                                       $this->globals['wgHooks'][$name][] = $callback;
+                               }
                        }
-                       $this->processed[] = 'Hooks';
                }
        }
 
@@ -183,7 +199,6 @@ class ExtensionProcessor implements Processor {
                                        $this->globals['wgNamespaceContentModels'][$id] = $ns['defaultcontentmodel'];
                                }
                        }
-                       $this->processed[] = 'namespaces';
                }
        }
 
@@ -215,7 +230,6 @@ class ExtensionProcessor implements Processor {
                        $this->globals["wgExtensionMessagesFiles"] += array_map( function( $file ) use ( $dir ) {
                                return "$dir/$file";
                        }, $info['ExtensionMessagesFiles'] );
-                       $this->processed[] = 'ExtensionMessagesFiles';
                }
        }
 
@@ -233,7 +247,6 @@ class ExtensionProcessor implements Processor {
                                        $this->globals["wgMessagesDirs"][$name][] = "$dir/$file";
                                }
                        }
-                       $this->processed[] = 'MessagesDirs';
                }
        }
 
@@ -242,11 +255,9 @@ class ExtensionProcessor implements Processor {
                        'path' => $path,
                        'type' => isset( $info['type'] ) ? $info['type'] : 'other',
                );
-               $this->processed[] = 'type';
                foreach ( self::$creditsAttributes as $attr ) {
                        if ( isset( $info[$attr] ) ) {
                                $credits[$attr] = $info[$attr];
-                               $this->processed[] = $attr;
                        }
                }
 
@@ -266,7 +277,6 @@ class ExtensionProcessor implements Processor {
                                        $this->globals["wg$key"] = $val;
                                }
                        }
-                       $this->processed[] = 'config';
                }
        }
 
@@ -275,16 +285,19 @@ class ExtensionProcessor implements Processor {
                        foreach ( $info['ParserTestFiles'] as $path ) {
                                $this->globals['wgParserTestFiles'][] = "$dir/$path";
                        }
-                       $this->processed[] = 'ParserTestFiles';
                }
        }
 
        /**
         * @param string $name
-        * @param mixed $value
+        * @param array $value
         * @param array &$array
+        * @throws InvalidArgumentException
         */
        protected function storeToArray( $name, $value, &$array ) {
+               if ( !is_array( $value ) ) {
+                       throw new InvalidArgumentException( "The value for '$name' should be an array" );
+               }
                if ( isset( $array[$name] ) ) {
                        $array[$name] = array_merge_recursive( $array[$name], $value );
                } else {