Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a76cdec

Browse filesBrowse files
bug #41346 [WebProfilerBundle] Wrapping exception js in Sfjs check and also loading base_js Sfjs if needed (weaverryan)
This PR was merged into the 4.4 branch. Discussion ---------- [WebProfilerBundle] Wrapping exception js in Sfjs check and also loading base_js Sfjs if needed | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #41305 | License | MIT | Doc PR | Not needed This bug was introduced in #41168. Best viewed with: https://github.com/symfony/symfony/pull/41346/files?w=1 - we could also remove the new indentation in `exception.js`. In that PR, we innocently don't reload `Sfjs` if it doesn't exist. However, on an error page, that template ALSO adds an `Sfjs`, and that `Sfjs` is *smaller* - containing only a subset of the `Sfjs` functions. This is tricky, but this PR fixes it. Here are the various situations: 1) I hit an exception page. The `Sfjs` from `exception.js` is loaded first. This adds the smaller `Sfjs`. Then the `base_js.html.twig` version is hit. Because `Sfjs` is missing the `loadToolbar()` method, that code DOES run again to reinitialize it. 2) I am on a normal page, then travel to an exception page with Turbo. In this case, the original `Sfjs` from `base_js.html.twig` was processed. Then, on the exception page, the `Sfjs` from `exception.js` is ignored, as is the 2nd execution of `base_js.html.twig`. Overall, the JS could use some work for supporting things like Turbo (e.g. `DOMContentLoaded` doesn't work with Turbo, so the exception page JS is broken). But I wanted to focus on fixing the bug in this PR. As a reminder, #41168 (avoiding overriding `Sfjs`) was done to help with the AJAX toolbar and Turbo - it's explained in point (1) on #41168. Cheers! Commits ------- 5fa42f1 Wrapping exception js in Sfjs check and also loading base_js Sfjs if needed
2 parents 68224c2 + 5fa42f1 commit a76cdec
Copy full SHA for a76cdec

File tree

2 files changed

+237
-236
lines changed
Filter options

2 files changed

+237
-236
lines changed

‎src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
them as JavaScript source code. Always use '/*' comments instead
66
of '//' comments to avoid impossible-to-debug side-effects #}
77
8-
if (typeof Sfjs === 'undefined') {
8+
if (typeof Sfjs === 'undefined' || typeof Sfjs.loadToolbar === 'undefined') {
99
Sfjs = (function() {
1010
"use strict";
1111

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.