registration: Handle $wgExtensionCredits inside the ExtensionProcessor
[lhc/web/wiklou.git] / includes / registration / ExtensionProcessor.php
index a286f6b..13c450a 100644 (file)
@@ -57,8 +57,7 @@ class ExtensionProcessor implements Processor {
                'wgGroupPermissions' => 'array_plus_2d',
                'wgRevokePermissions' => 'array_plus_2d',
                'wgHooks' => 'array_merge_recursive',
-               // credits are handled in the ExtensionRegistry
-               //'wgExtensionCredits' => 'array_merge_recursive',
+               'wgExtensionCredits' => 'array_merge_recursive',
                'wgExtraGenderNamespaces' => 'array_plus',
                'wgNamespacesWithSubpages' => 'array_plus',
                'wgNamespaceContentModels' => 'array_plus',
@@ -102,6 +101,7 @@ class ExtensionProcessor implements Processor {
                'ParserTestFiles',
                'AutoloadClasses',
                'manifest_version',
+               'load_composer_autoloader',
        );
 
        /**
@@ -293,6 +293,11 @@ class ExtensionProcessor implements Processor {
                }
        }
 
+       /**
+        * @param string $path
+        * @param array $info
+        * @throws Exception
+        */
        protected function extractCredits( $path, array $info ) {
                $credits = array(
                        'path' => $path,
@@ -304,7 +309,18 @@ class ExtensionProcessor implements Processor {
                        }
                }
 
-               $this->credits[$credits['name']] = $credits;
+               $name = $credits['name'];
+
+               // If someone is loading the same thing twice, throw
+               // a nice error (T121493)
+               if ( isset( $this->credits[$name] ) ) {
+                       $firstPath = $this->credits[$name]['path'];
+                       $secondPath = $credits['path'];
+                       throw new Exception( "It was attempted to load $name twice, from $firstPath and $secondPath." );
+               }
+
+               $this->credits[$name] = $credits;
+               $this->globals['wgExtensionCredits'][$credits['type']][] = $credits;
        }
 
        /**
@@ -353,4 +369,15 @@ class ExtensionProcessor implements Processor {
                        $array[$name] = $value;
                }
        }
+
+       public function getExtraAutoloaderPaths( $dir, array $info ) {
+               $paths = array();
+               if ( isset( $info['load_composer_autoloader'] ) && $info['load_composer_autoloader'] === true ) {
+                       $path = "$dir/vendor/autoload.php";
+                       if ( file_exists( $path ) ) {
+                               $paths[] = $path;
+                       }
+               }
+               return $paths;
+       }
 }