registration: Remove implementation of custom processors for now
authorKunal Mehta <legoktm@gmail.com>
Mon, 18 May 2015 05:48:58 +0000 (22:48 -0700)
committerKunal Mehta <legoktm@gmail.com>
Mon, 18 May 2015 05:48:58 +0000 (22:48 -0700)
The current implementation is broken due to the array_merge_recursive it
does on all the data, which would have broken things like
$wgGroupPermissions which requires special handling.

Remove the current implementation for now while we re-evaluatate how to
do this properly, and whether it is even needed.

Bug: T99492
Change-Id: I886892e6fd12d51446ede4fc7e6ef1371542b77e

includes/registration/ExtensionRegistry.php

index d938f07..40ae2eb 100644 (file)
@@ -38,13 +38,6 @@ class ExtensionRegistry {
         */
        protected $attributes = array();
 
-       /**
-        * Processors, 'default' should be set by subclasses in the constructor
-        *
-        * @var Processor[]
-        */
-       protected $processors = array();
-
        /**
         * @var ExtensionRegistry
         */
@@ -119,6 +112,7 @@ class ExtensionRegistry {
        public function readFromQueue( array $queue ) {
                $data = array( 'globals' => array( 'wgAutoloadClasses' => array() ) );
                $autoloadClasses = array();
+               $processor = new ExtensionProcessor();
                foreach ( $queue as $path => $mtime ) {
                        $json = file_get_contents( $path );
                        if ( $json === false ) {
@@ -132,36 +126,18 @@ class ExtensionRegistry {
                        // Set up the autoloader now so custom processors will work
                        $GLOBALS['wgAutoloadClasses'] += $autoload;
                        $autoloadClasses += $autoload;
-                       if ( isset( $info['processor'] ) ) {
-                               $processor = $this->getProcessor( $info['processor'] );
-                       } else {
-                               $processor = $this->getProcessor( 'default' );
-                       }
                        $processor->extractInfo( $path, $info );
                }
-               foreach ( $this->processors as $processor ) {
-                       $data = array_merge_recursive( $data, $processor->getExtractedInfo() );
-               }
+               $data = $processor->getExtractedInfo();
+               // Need to set this so we can += to it later
+               $data['globals']['wgAutoloadClasses'] = array();
                foreach ( $data['credits'] as $credit ) {
                        $data['globals']['wgExtensionCredits'][$credit['type']][] = $credit;
                }
-               $this->processors = array(); // Reset
                $data['autoload'] = $autoloadClasses;
                return $data;
        }
 
-       protected function getProcessor( $type ) {
-               if ( !isset( $this->processors[$type] ) ) {
-                       $processor = $type === 'default' ? new ExtensionProcessor() : new $type();
-                       if ( !$processor instanceof Processor ) {
-                               throw new Exception( "$type is not a Processor" );
-                       }
-                       $this->processors[$type] = $processor;
-               }
-
-               return $this->processors[$type];
-       }
-
        protected function exportExtractedData( array $info ) {
                foreach ( $info['globals'] as $key => $val ) {
                        if ( !isset( $GLOBALS[$key] ) || !$GLOBALS[$key] ) {