?
avatar roland-d
roland-d
20 Jan 2019

Steps to reproduce the issue

  1. Enable the Debug System in Global configuration
  2. Logout
  3. Check the browser console window and notice JavaScript errors because jQuery is not loaded

Debugging this issue I found out that:

  1. Script tags are placed in the body instead of the head
  2. The admin page is rendered from the error page handler

This is caused because this line of code in the libraries/src/Application/CMSApplication.php file:
$uri = clone Uri::getInstance();

gets a value of:
http://joomlacms.test/media/vendor/css-vars-ponyfill/js/css-vars-ponyfill.js.map

The router can't find a route for this and throws an exception.

Expected result

Debug bar is displayed when enabled and page is rendered using the regular page renderer.

Actual result

No debug bar is displayed and the page is rendered using the error page renderer.

System information (as much as possible)

Joomla 4.0-dev branch
PHP 7.2 / PHP 7.3
MySQL 5.7

Additional comments

avatar roland-d roland-d - open - 20 Jan 2019
avatar joomla-cms-bot joomla-cms-bot - change - 20 Jan 2019
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 20 Jan 2019
avatar dgrammatiko
dgrammatiko - comment - 20 Jan 2019

Check the browser console window and notice JavaScript errors because jQuery is not loaded

If DebugBar is depending on jQuery then it should make sure it's loaded. The templates should not force jQuery.

Script tags are placed in the body instead of the head

This is intended. Actually if devs were more aware of the benefits of having the scripts before the body closing tags the product will be so much more performant...

In sort add: HTMLHelper::_('jquery.framework') in the debugBar layouts...

avatar roland-d
roland-d - comment - 21 Jan 2019

@dgrammatiko

In sort add: HTMLHelper::_('jquery.framework') in the debugBar layouts...

Too good to be true, it isn't that easy otherwise I would have done so already.

This line removes jQuery again:

$debugBarRenderer->disableVendor('jquery');

If you remove that line, jQuery is added twice. Regardless of that, this code is placed in the head and Joomla is placing JS files at the end, so jQuery is loaded too late.

All I can see for now is that we do remove that line and then remove the debugbar jQuery from the output.

@elkuku Any ideas here?

avatar mbabker
mbabker - comment - 21 Jan 2019

The line you linked disables the jQuery library shipped with the DebugBar package, that has no affect on jQuery loaded through the HTML or Document APIs.

avatar dgrammatiko
dgrammatiko - comment - 22 Jan 2019

This line removes jQuery again:

So after the line add the Joomla's HTMLHelper for loading the jQuery. That should do the trick!

Edit: I just saw that this is using the assets manager and quite honestly I have no clue, still HTMLHelper should work but it's not the right way to mix different methods

avatar dgrammatiko
dgrammatiko - comment - 22 Jan 2019

@roland-d so I figure out why this is breaking. In all the files in the dir: plugins/system/debug/DataCollector/InfoCollector.php the assets are handled by the DebugBar. That's wrong, we need to use Joomla's API to ensure consistency. So

/**
* Returns an array with the following keys:
* - base_path
* - base_url
* - css: an array of filenames
* - js: an array of filenames
*
* @since 4.0.0
* @return array
*/
public function getAssets(): array
{
return array(
'js' => \JUri::root(true) . '/media/plg_system_debug/widgets/info/widget.min.js',
'css' => \JUri::root(true) . '/media/plg_system_debug/widgets/info/widget.min.css',
);
}

this needs to return an empty array but the function needs to use HTMLHelper to load the js and css. Also since we're here we need to place the actual files in a js/ and css/ folder so we can use the ('relative' => true) and also set the media version to auto.

That should do it

avatar dgrammatiko
dgrammatiko - comment - 22 Jan 2019
avatar Fedik
Fedik - comment - 22 Jan 2019

that because someone put <jdoc:include type="scripts"/> at bottom of the login layout, with a hope that everything will be fine, but it is not ?

please test #23639

avatar Fedik
Fedik - comment - 22 Jan 2019

ah, cache hahaha
@dgrammatiko was faster, I close mine

avatar roland-d
roland-d - comment - 23 Jan 2019

@dgrammatiko Thank you ? This works.

@Fedik Can you test #23639 as well?

Closing this as we have a PR.

avatar roland-d roland-d - change - 23 Jan 2019
Status New Closed
Closed_Date 0000-00-00 00:00:00 2019-01-23 06:44:03
Closed_By roland-d
avatar roland-d roland-d - close - 23 Jan 2019

Add a Comment

Login with GitHub to post a comment