Fixed really bad stuff going on with running hooks at the file level. Now, ResourceLo...
authorTrevor Parscal <tparscal@users.mediawiki.org>
Wed, 15 Sep 2010 18:15:36 +0000 (18:15 +0000)
committerTrevor Parscal <tparscal@users.mediawiki.org>
Wed, 15 Sep 2010 18:15:36 +0000 (18:15 +0000)
includes/OutputPage.php
includes/ResourceLoader.php

index cec102a..e0ba853 100644 (file)
@@ -2294,6 +2294,8 @@ class OutputPage {
                foreach ( (array) $modules as $name ) {
                        $moduleGroups[strpos( $name, 'user' ) === 0 ? 'user' : null][] = $name;
                }
+               // Make sure ResourceLoader is ready for use
+               ResourceLoader::initialize();
                $links = '';
                foreach ( $moduleGroups as $group => $modules ) {
                        if ( count( $modules ) ) {
index 6fb9105..cb759ca 100644 (file)
@@ -29,6 +29,7 @@ class ResourceLoader {
 
        // @var array list of module name/ResourceLoaderModule object pairs
        protected static $modules = array();
+       protected static $initialized = false;
 
        /* Protected Static Methods */
 
@@ -84,6 +85,17 @@ class ResourceLoader {
 
        /* Static Methods */
 
+       public static function initialize() {
+               global $IP;
+               
+               if ( !self::$initialized ) {
+                       // Do this first just in case someone accidentally adds a call to ResourceLoader::initialize in their hook
+                       self::$initialized = true;
+                       self::register( include( "$IP/resources/Resources.php" ) );
+                       wfRunHooks( 'ResourceLoaderRegisterModules' );
+               }
+       }
+
        /**
         * Registers a module with the ResourceLoader system.
         *
@@ -194,6 +206,9 @@ class ResourceLoader {
                global $wgResourceLoaderVersionedClientMaxage, $wgResourceLoaderVersionedServerMaxage;
                global $wgResourceLoaderUnversionedServerMaxage, $wgResourceLoaderUnversionedClientMaxage;
 
+               // Register modules
+               self::initialize();
+               
                // Split requested modules into two groups, modules and missing
                $modules = array();
                $missing = array();
@@ -323,7 +338,4 @@ class ResourceLoader {
                        }
                }
        }
-}
-
-ResourceLoader::register( include( "$IP/resources/Resources.php" ) );
-wfRunHooks( 'ResourceLoaderRegisterModules' );
\ No newline at end of file
+}
\ No newline at end of file