SkinTemplate: Move bottomScripts() back sightly
authorTimo Tijhof <krinklemail@gmail.com>
Tue, 16 Aug 2016 21:12:55 +0000 (16:12 -0500)
committerTimo Tijhof <krinklemail@gmail.com>
Tue, 16 Aug 2016 21:22:22 +0000 (16:22 -0500)
Follows-up 80e5b160e95fc8a96db.

In 80e5b160e, the module queue formatting was changed and was now fixed at
the first call to headElement() or bottomScripts(), instead of being kept
dynamic in between. Doing so fixed various bugs but also broke a few cases
where things still add to the bottom queue after the headElement() is
already created (such as sidebar).

In 95fc8a96db, the bottomScripts() method was moved to the very bottom of
prepareQuickTemplate(). This was imho too far and not needed because any line
after 'headElement()' element is effectively the same since that will commit
the queue.

It also changed the order of hook execution, from:
- SkinAfterBottomScripts, SkinTemplateOutputPageBeforeExec, SkinAfterContent
to:
- SkinTemplateOutputPageBeforeExec, SkinAfterContent, SkinAfterBottomScripts

With the latter no longer being able to add things to the module queue since
it now runs after headElement() commits the queue.

Move it back up, to right above headElement(). This way the order is the
same as before 95fc8a96db (first bottomScripts, then headElement). But still
after all other properties, thus still keeping the regression from 80e5b160e
fixed.

Bug: T87871
Change-Id: I8f774880e60e31c0e996b20acdc5ce5e42a84b01

includes/skins/SkinTemplate.php

index 749a686..b4be461 100644 (file)
@@ -478,6 +478,9 @@ class SkinTemplate extends Skin {
                $tpl->set( 'sidebar', $this->buildSidebar() );
                $tpl->set( 'nav_urls', $this->buildNavUrls() );
 
+               // Do this last in case hooks above add bottom scripts
+               $tpl->set( 'bottomscripts', $this->bottomScripts() );
+
                // Set the head scripts near the end, in case the above actions resulted in added scripts
                $tpl->set( 'headelement', $out->headElement( $this ) );
 
@@ -508,9 +511,6 @@ class SkinTemplate extends Skin {
                // See Skin::afterContentHook() for further documentation.
                $tpl->set( 'dataAfterContent', $this->afterContentHook() );
 
-               // Do this last in case hooks above add bottom scripts
-               $tpl->set( 'bottomscripts', $this->bottomScripts() );
-
                return $tpl;
        }