Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.0] Debug does not display on frontend error page #32354

Closed
infograf768 opened this issue Feb 8, 2021 · 20 comments
Closed

[4.0] Debug does not display on frontend error page #32354

infograf768 opened this issue Feb 8, 2021 · 20 comments

Comments

@infograf768
Copy link
Member

infograf768 commented Feb 8, 2021

Steps to reproduce the issue

Enable debug in back-end
Log as admin in frontend
Enter a fake url in frontend

Expected result

Error page is loaded.
Debug should display at bottom of page

Actual result

Debug does not display although we do have
<jdoc:include type="modules" name="debug" style="none" />
in error.php

@dgrammatiko
Copy link
Contributor

Debug is NOT using the template position

echo str_replace('</body>', implode('', $html) . '</body>', $contents);
Also requires a logged in Admin user

@infograf768
Copy link
Member Author

I am logged as Admin.

How to solve this?

@infograf768
Copy link
Member Author

code is in line 346
echo str_replace('</body>', $debugBarRenderer->renderHead() . $debugBarRenderer->render() . '</body>', $contents);

and the whole code is present before </body> in page source.

@dgrammatiko
Copy link
Contributor

Do you have any errors in the browser's console?

@infograf768
Copy link
Member Author

Many

Uncaught ReferenceError: jQuery is not defined
    <anonymous> http://localhost:8888/newfolder/joomla40/media/vendor/debugbar/debugbar.js:4
debugbar.js:4:5
10:55:18.428
Uncaught TypeError: PhpDebugBar.utils is undefined
    <anonymous> http://localhost:8888/newfolder/joomla40/media/vendor/debugbar/widgets.js:14
    <anonymous> http://localhost:8888/newfolder/joomla40/media/vendor/debugbar/widgets.js:583
widgets.js:14:18
10:55:18.428
Uncaught TypeError: PhpDebugBar.Widget is undefined
    <anonymous> http://localhost:8888/newfolder/joomla40/media/vendor/debugbar/openhandler.js:13
    <anonymous> http://localhost:8888/newfolder/joomla40/media/vendor/debugbar/openhandler.js:202
openhandler.js:13:5
10:55:18.428
Uncaught TypeError: PhpDebugBar.utils is undefined
    <anonymous> http://localhost:8888/newfolder/joomla40/media/plg_system_debug/widgets/info/widget.min.js:1
    <anonymous> http://localhost:8888/newfolder/joomla40/media/plg_system_debug/widgets/info/widget.min.js:1
widget.min.js:1:20
10:55:18.428
Uncaught TypeError: PhpDebugBar.utils is undefined
    <anonymous> http://localhost:8888/newfolder/joomla40/media/plg_system_debug/widgets/sqlqueries/widget.min.js:1
    <anonymous> http://localhost:8888/newfolder/joomla40/media/plg_system_debug/widgets/sqlqueries/widget.min.js:1
widget.min.js:1:20

etc.

@dgrammatiko
Copy link
Contributor

jQuery is not defined

There you go. Add before

JHtml::_('bootstrap.tooltip');

JHtml::_('jquery.framework');

@infograf768
Copy link
Member Author

You are quoting staging.
I am speaking of 4.0

@infograf768
Copy link
Member Author

If I add HTMLHelper::_('jquery.framework'); on top of error.php, then it works.

@dgrammatiko
Copy link
Contributor

Weird the jQuery is defined as dependency here:

Do you have a js file loaded in the browser with path media/plg_system_debug/js/debug.min.js ?

@infograf768
Copy link
Member Author

infograf768 commented Feb 8, 2021

No, in index.php (where it works) as well as error.php
I have at bottom of page
<script type="text/javascript" src="/newfolder/joomla40/media/vendor/debugbar/debugbar.js" defer></script>

EDIT: In fact I have them in index.php, not in error.php

@Fedik
Copy link
Member

Fedik commented Feb 8, 2021

It worked for me yesterday, without errors. Today not tested.
Any changes in 4.0-dev branch happen recently? :)

@infograf768
Copy link
Member Author

@Fedik, have you tested with error.php?

@Fedik
Copy link
Member

Fedik commented Feb 8, 2021

ahh, I misunderstood, sorry,
yeah it broken on 404 page

@Fedik
Copy link
Member

Fedik commented Feb 8, 2021

okay I see,
That because it is DocumentError and it a different Document instance from initial.
debug.js attached to original DocuemtHtml, but "on error" the error handler proceed DocumentError

I will try to look later, how to fix that.

@infograf768
Copy link
Member Author

You mean
* @todo Change this renderer to use JDocumentHtml instead of JDocumentError, the latter is only used for B/C at this time
in
/libraries/src/Error/Renderer/HtmlRenderer.php

?

@Fedik
Copy link
Member

Fedik commented Feb 8, 2021

@Fedik
Copy link
Member

Fedik commented Feb 8, 2021

hm, or maybe Yes
well, it confusing 😄

@Fedik
Copy link
Member

Fedik commented Feb 8, 2021

but the document instance changes in

// Reset the document object in the factory, this gives us a clean slate and lets everything render properly
Factory::$document = $renderer->getDocument();
Factory::getApplication()->loadDocument(Factory::$document);

need to change how the plugin attach the script

@infograf768
Copy link
Member Author

OK

@Fedik
Copy link
Member

Fedik commented Feb 8, 2021

please test #32358

@Quy Quy closed this as completed Feb 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants