Merge "Add CollationFa"
[lhc/web/wiklou.git] / includes / registration / ExtensionRegistry.php
index b5c70e9..70dc624 100644 (file)
@@ -31,7 +31,7 @@ class ExtensionRegistry {
        /**
         * Bump whenever the registration cache needs resetting
         */
-       const CACHE_VERSION = 3;
+       const CACHE_VERSION = 4;
 
        /**
         * Special key that defines the merge strategy
@@ -59,6 +59,13 @@ class ExtensionRegistry {
         */
        protected $queued = [];
 
+       /**
+        * Whether we are done loading things
+        *
+        * @var bool
+        */
+       private $finished = false;
+
        /**
         * Items in the JSON file that aren't being
         * set as globals
@@ -114,12 +121,23 @@ class ExtensionRegistry {
                $this->queued[$path] = $mtime;
        }
 
+       /**
+        * @throws MWException If the queue is already marked as finished (no further things should
+        *  be loaded then).
+        */
        public function loadFromQueue() {
                global $wgVersion;
                if ( !$this->queued ) {
                        return;
                }
 
+               if ( $this->finished ) {
+                       throw new MWException(
+                               "The following paths tried to load late: "
+                               . implode( ', ', array_keys( $this->queued ) )
+                       );
+               }
+
                // A few more things to vary the cache on
                $versions = [
                        'registration' => self::CACHE_VERSION,
@@ -164,6 +182,15 @@ class ExtensionRegistry {
                $this->queued = [];
        }
 
+       /**
+        * After this is called, no more extensions can be loaded
+        *
+        * @since 1.29
+        */
+       public function finish() {
+               $this->finished = true;
+       }
+
        /**
         * Process a queue of extensions and return their extracted data
         *
@@ -285,9 +312,6 @@ class ExtensionRegistry {
                foreach ( $info['autoloaderPaths'] as $path ) {
                        require_once $path;
                }
-               foreach ( $info['callbacks'] as $cb ) {
-                       call_user_func( $cb );
-               }
 
                $this->loaded += $info['credits'];
                if ( $info['attributes'] ) {
@@ -297,6 +321,10 @@ class ExtensionRegistry {
                                $this->attributes = array_merge_recursive( $this->attributes, $info['attributes'] );
                        }
                }
+
+               foreach ( $info['callbacks'] as $name => $cb ) {
+                       call_user_func( $cb, $info['credits'][$name] );
+               }
        }
 
        /**