-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[WebProfilerBundle] Add missing Javascript function to prevent undefined function #48037
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
Conversation
The issue rather comes from the fact So if I don’t even know why there are two flavors of |
lol you literally just paraphrased what I had already said :)
I guess you could show exceptions with |
Quite the opposite in fact: you’re saying Given |
I did think that, but I like to assume everything in Symfony has a reason to be there and that the code it mostly bug free. Maybe. I assume too much :) So you would propose to remove calls to this function in the
The calls to the function are outside the "if undefined" block, and so they do get called. |
PR updated now to just that change. |
If |
I think every occurrence of Maybe you could change the PR’s title too! |
Friendly ping @PhilETaylor |
Thanks. Yup I know I suck :) I have this one and the Doctrine profiler PR to revisit, it's still on my plate to do both. Sorry for the delay. |
Closing as this stalled. Please resubmit when you can. Or maybe @MatTheCat if you're up to? |
I opened #50108 because we missed the big picture in this PR 😅 |
…JavaScript (MatTheCat) This PR was merged into the 5.4 branch. Discussion ---------- [ErrorHandler] Prevent conflicts with WebProfilerBundle’s JavaScript | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #50108 | License | MIT | Doc PR | N/A ErrorHandler’s `exception.js` and WebProfilerBundle’s `base_js.html.twig` both expose a global `Sfjs` variable, which create conflicts (see linked issue e.g.). As the exception page - does not make use of `Sfjs` - is not extensible I updated `exception.js` to not create any global scope variable. I also removed `DOMContentLoaded` listeners as the script is run inline at the end of the document. This PR stems from #48037. Hiding whitespaces will produce a much more readable diff. Commits ------- e331b28 Do not expose `Sfjs` as it is unused and conflicts with WebProfilerBundle’s
So.... To replicate create a demo app with Symfony 5.4, 6.1, 6.2....
The result is a Javascript error in the console log:
Now, Javascript in the profiler is loaded from two places (and each of these files has a header alerting you to that fact and that changes in one should be considered for the other too)
Both files will only run their definition of the
Sfjs
if thetypeof Sfjs === 'undefined'
is true... so if one loads before the other then the latter will not redefine theSfjs
However, what is happening is that the
base_js.html.twig
is defining theSfjs
object beforeexception.js
gets a chance - and because theSfjs.createFilters
function is not inbase_js.html.twig
its not defined and so the error message tells us that.This PR duplicates the method into the
base_js.html.twig
version of theSfjs
object so that it can be called from the code (at the bottom of)exception.js
and thus the console.log error message is now gone.The code provided in this PR is not my code, its direct copy of the code from
exception.js