Allow namespaces defined in extension.json to be overwritten locally.
[lhc/web/wiklou.git] / includes / registration / ExtensionProcessor.php
index 26fbfa1..feffac1 100644 (file)
@@ -26,6 +26,7 @@ class ExtensionProcessor implements Processor {
                'ExtensionEntryPointListFiles',
                'ExtensionFunctions',
                'FeedClasses',
+               'FileExtensions',
                'FilterLogTypes',
                'GrantPermissionGroups',
                'GrantPermissions',
@@ -42,6 +43,7 @@ class ExtensionProcessor implements Processor {
                'LogRestrictions',
                'LogTypes',
                'MediaHandlers',
+               'PasswordPolicy',
                'RateLimits',
                'RecentChangesFlags',
                'RemoveCredentialsBlacklist',
@@ -72,6 +74,7 @@ class ExtensionProcessor implements Processor {
                'wgNamespaceContentModels' => 'array_plus',
                'wgNamespaceProtection' => 'array_plus',
                'wgNamespacesWithSubpages' => 'array_plus',
+               'wgPasswordPolicy' => 'array_merge_recursive',
                'wgRateLimits' => 'array_plus_2d',
                'wgRevokePermissions' => 'array_plus_2d',
        ];
@@ -138,6 +141,7 @@ class ExtensionProcessor implements Processor {
 
        /**
         * Things to be called once registration of these extensions are done
+        * keyed by the name of the extension that it belongs to
         *
         * @var callable[]
         */
@@ -177,11 +181,11 @@ class ExtensionProcessor implements Processor {
                $this->extractResourceLoaderModules( $dir, $info );
                $this->extractServiceWiringFiles( $dir, $info );
                $this->extractParserTestFiles( $dir, $info );
+               $name = $this->extractCredits( $path, $info );
                if ( isset( $info['callback'] ) ) {
-                       $this->callbacks[] = $info['callback'];
+                       $this->callbacks[$name] = $info['callback'];
                }
 
-               $this->extractCredits( $path, $info );
                foreach ( $info as $key => $val ) {
                        if ( in_array( $key, self::$globalSettings ) ) {
                                $this->storeToArray( $path, "wg$key", $val, $this->globals );
@@ -212,13 +216,7 @@ class ExtensionProcessor implements Processor {
        }
 
        public function getRequirements( array $info ) {
-               $requirements = [];
-               $key = ExtensionRegistry::MEDIAWIKI_CORE;
-               if ( isset( $info['requires'][$key] ) ) {
-                       $requirements[$key] = $info['requires'][$key];
-               }
-
-               return $requirements;
+               return isset( $info['requires'] ) ? $info['requires'] : [];
        }
 
        protected function extractHooks( array $info ) {
@@ -243,8 +241,15 @@ class ExtensionProcessor implements Processor {
        protected function extractNamespaces( array $info ) {
                if ( isset( $info['namespaces'] ) ) {
                        foreach ( $info['namespaces'] as $ns ) {
-                               $id = $ns['id'];
-                               $this->defines[$ns['constant']] = $id;
+                               if ( defined( $ns['constant'] ) ) {
+                                       // If the namespace constant is already defined, use it.
+                                       // This allows namespace IDs to be overwritten locally.
+                                       $id = constant( $ns['constant'] );
+                               } else {
+                                       $id = $ns['id'];
+                                       $this->defines[ $ns['constant'] ] = $id;
+                               }
+
                                if ( !( isset( $ns['conditional'] ) && $ns['conditional'] ) ) {
                                        // If it is not conditional, register it
                                        $this->attributes['ExtensionNamespaces'][$id] = $ns['name'];
@@ -332,6 +337,7 @@ class ExtensionProcessor implements Processor {
        /**
         * @param string $path
         * @param array $info
+        * @return string Name of thing
         * @throws Exception
         */
        protected function extractCredits( $path, array $info ) {
@@ -357,6 +363,8 @@ class ExtensionProcessor implements Processor {
 
                $this->credits[$name] = $credits;
                $this->globals['wgExtensionCredits'][$credits['type']][] = $credits;
+
+               return $name;
        }
 
        /**