registration: Have wfLoadExtension() (and similar) use the queue
authorKunal Mehta <legoktm@gmail.com>
Mon, 30 Mar 2015 21:35:45 +0000 (14:35 -0700)
committerCatrope <roan.kattouw@gmail.com>
Tue, 31 Mar 2015 00:47:15 +0000 (00:47 +0000)
Right now wfLoadExtension() and related functions explicitly load
extensions immediately, bypassing the queue. This was done to be
extremely backwards-compatible with the old require_once style of
loading which does the same.

However, for a future configuration database to work, we need to be able
to reliably load extensions after configuration (LocalSettings.php) is
loaded, which is currently at the top of Setup.php. Rather than doing
this later, we should do this now to make sure the registration system
will be able to handle it.

In Wikimedia production, excentions are currently being loaded with
direct calls to:
  ExtensionRegistry::getInstance()->queue(...);
so we know that this should work, but that is not a nice API for sysadmins
and developers to be entering into LocalSettings.php.

If for some reason an extension really needs to be loaded immediately,
they can still call:
  ExtensionRegistry::getInstance()->loadFromQueue();
But that should be the exception, not the norm.

Change-Id: I72672e5c9541ede02d09f548c39ef6c8df0ec78a

includes/GlobalFunctions.php

index a9ed60f..bc3a46b 100644 (file)
@@ -166,12 +166,8 @@ if ( !function_exists( 'hash_equals' ) ) {
 /**
  * Load an extension
  *
- * This is the closest equivalent to:
- *   require_once "$IP/extensions/$name/$name.php";
- * as it will process and load the extension immediately.
- *
- * However, batch loading with wfLoadExtensions will
- * be more performant.
+ * This queues an extension to be loaded through
+ * the ExtensionRegistry system.
  *
  * @param string $name Name of the extension to load
  * @param string|null $path Absolute path of where to find the extension.json file
@@ -181,7 +177,7 @@ function wfLoadExtension( $name, $path = null ) {
                global $IP;
                $path = "$IP/extensions/$name/extension.json";
        }
-       ExtensionRegistry::getInstance()->load( $path );
+       ExtensionRegistry::getInstance()->queue( $path );
 }
 
 /**
@@ -202,8 +198,6 @@ function wfLoadExtensions( array $exts ) {
        foreach ( $exts as $ext ) {
                $registry->queue( "$IP/extensions/$ext/extension.json" );
        }
-
-       $registry->loadFromQueue();
 }
 
 /**
@@ -218,7 +212,7 @@ function wfLoadSkin( $name, $path = null ) {
                global $IP;
                $path = "$IP/skins/$name/skin.json";
        }
-       ExtensionRegistry::getInstance()->load( $path );
+       ExtensionRegistry::getInstance()->queue( $path );
 }
 
 /**
@@ -233,8 +227,6 @@ function wfLoadSkins( array $skins ) {
        foreach ( $skins as $skin ) {
                $registry->queue( "$IP/skins/$skin/skin.json" );
        }
-
-       $registry->loadFromQueue();
 }
 
 /**