Add OutputPageScriptsForBottomQueue hook
authorKunal Mehta <legoktm@gmail.com>
Sun, 22 Jun 2014 08:48:16 +0000 (01:48 -0700)
committerTimo Tijhof <krinklemail@gmail.com>
Sun, 20 Jul 2014 00:16:00 +0000 (02:16 +0200)
This allows for extensions to add specific modules into the bottom
queue.

Bug: 62602
Change-Id: Ifccac7889e80b2f674cd54bb4ad3e53c6aa1dfa1

RELEASE-NOTES-1.24
docs/hooks.txt
includes/OutputPage.php

index 197fd24..d76cd29 100644 (file)
@@ -118,6 +118,8 @@ production.
 * Upgrade jQuery Cookie to v1.2.0.
 * (bug 20476) Add a "viewsuppressed" user right to be able to view
   suppressed content but not suppress it ("suppressrevision" right).
+* Added a new hook, "OutputPageScriptsForBottomQueue", to add modules to the
+  bottom queue that should be requested in a dedicated <script> request.
 
 === Bug fixes in 1.24 ===
 * (bug 49116) Footer copyright notice is now always displayed in user language
index 065c7d3..3ee1221 100644 (file)
@@ -1871,6 +1871,14 @@ $categories: associative array, keys are category names, values are category
 $links: array, intended to hold the result. Must be an associative array with
   category types as keys and arrays of HTML links as values.
 
+'OutputPageScriptsForBottomQueue': Allows adding modules to the bottom queue
+that should be requested in a dedicated <script> request. In most cases you'll
+want to use OutputPage::addModules instead (from another hook) which allows
+ResourceLoader to better combine requests and allows the module load requests
+to be cached better. Typically you'd only use this for user-specific modules.
+$out: OutputPage instance
+&$modules: Array of modules names to add to the bottom queue
+
 'PageContentInsertComplete': After a new article is created.
 $wikiPage: WikiPage created
 $user: User creating the article
index 0dca0da..19b2240 100644 (file)
@@ -2895,7 +2895,7 @@ $templates
 
                // Startup - this will immediately load jquery and mediawiki modules
                $links = array();
-               $links[] = $this->makeResourceLoaderLink( 'startup', ResourceLoaderModule::TYPE_SCRIPTS, true );
+               $links[] = $this->makeResourceLoaderLink( 'startup', ResourceLoaderModule::TYPE_SCRIPTS, /* $useESI =  */ true );
 
                // Load config before anything else
                $links[] = Html::inlineScript(
@@ -3017,6 +3017,14 @@ $templates
                        /* $useESI = */ false, /* $extraQuery = */ array(), /* $loadCall = */ $inHead
                );
 
+               $modules = array();
+               wfRunHooks( 'OutputPageScriptsForBottomQueue', array( $this, &$modules ) );
+               if ( $modules ) {
+                       $links[] = $this->makeResourceLoaderLink( $modules, ResourceLoaderModule::TYPE_COMBINED,
+                               /* $useESI = */ false, /* $extraQuery = */ array(), /* $loadCall = */ $inHead
+                       );
+               }
+
                return self::getHtmlFromLoaderLinks( $links );
        }