-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Fatal PHP errors, like syntax errors, not an object, etc, are not shown properly when using PHP 7 #10732
Comments
Here are the lines that get the error code and error message and print it Backend: Frontend:
but you can see that they do not call: which is needed for PHP 7 because the getMessage() does not include file and line information Probably we need to add something like the following code, to the error.php of the templates ?:
|
PHP 7 made no changes to how stack traces are processed, so if you make such changes you do NOT need to wrap it in a version comparison conditional. See https://groups.google.com/d/topic/joomla-dev-cms/bPsyhj55qcA/discussion for more context. |
about searching i only tried to find the issue here, with a quick look i did not find, about version compare, indeed version compare is not needed in the link that reported the issue before, it is suggested to print the file and line only if debug is ON is wrong
thus getFile and getLine should not be inside currently
[EDIT] |
All that can be done from the Joomla side is expand what data is displayed on the error page when it is given a Throwable. The fact that PHP core changed some language errors into catchable Throwable instances is why people seem to think that error handling/reporting has changed between PHP 7, but the internal behaviors of Throwable objects hasn't changed at all (the stack trace purposefully omits the line the object was thrown on, there was a lengthy discussion on the PHP Internals mailing list recently on this; and there is no method on Throwable that is a concatenation of The language changes most noticeably cause two behavioral differences:
Yes they should. People freak out when file paths are displayed back to a user, even if they are sanitized beforehand. It shouldn't be a default behavior to spit this stuff out on the error page. |
you are right, but i did not suggest such a thing in my last message please look at the picture, |
Thus setting error_reporting to
i think these were and should remain indepedent
|
If a site has turned on error reporting (mistakenly or otherwise), if the checks are dependent only on the error reporting variable then the stack trace and error file/line are displayed. If it's left to only be displayed when debug mode is enabled, that's a more explicit action to display this extra information that's really only relevant when debugging the issue. It might seem bass ackwards, but given Joomla's user base isn't purely developers, it's better to rely on debug mode here versus error reporting, especially given how easily people claim that a file path is an information disclosure security issue. |
Ok i understand your point but do we want the Joomla debug to be always ON while we are developing ?
even 0.5 (unneeded) seconds more on pages while work is a little annoying anyway if such a behaviour, is introduced, then no problem for me
in any case getFile() and getLine() need to be added somewhere
|
about this argument
Your argument has some logic as i acknowledged But it makes little sense to print the file and line information for
but hide these for fatal errors so that we make difficult for people to get support OK, it is possible to enforce such a new behaviour for PHP warnings and notices, if it is decided that Joomla will override the PHP error handler with a custom one ! so what will happen ? will Joomla override the PHP error handler to force removal of ... file / line in PHP notices and warnings
also will Joomla remove parameter error reporting ? I am only asking, this is not urgent, but this new behaviour of fatal errors will be more often in near future, as more users will have PHP7 on their web-sites |
At the end of the day usually what I suggest gets ignored anyway. But considering people groan and raise security issues about the fact error messages have SQL queries and file paths in them, I'd suggest NOT including those types of output on error pages without some sort of explicit action beyond enable/disable error reporting. Get #10341 tested and you don't need to worry about this stuff showing up on screen. It'll write to the error logs. As for replacing PHP's default error handler with a "custom" handler for Joomla, there are probably people who would say yes Joomla needs to do this to mask "sensitive info". But, also consider that the error handler is massively different than the callback function used for the exception handler (which prevents a fatal error about having an uncaught exception). So that's not just a simple "hey, an |
I will, thanks |
Closed based on comments above and the presence of a PR for testing This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/10732. |
Steps to reproduce the issue
Use PHP7 and J3.5.1 (or latest staging)
add a syntax or other fatal error in any PHP file
Expected result
If error reporting is ON then at least the FILE and LINE that produced the fatal error should be shown
Actual result
The file and line that created the fatal error, are not shown
System information (as much as possible)
PHP7.x
J3.5.x (or latest staging)
Additional comments
The reason is that we do not let the PHP7 default error handler to produces it own output,
so far so good, but then the Joomla error handler does not seem to call
...error->getFile()
...error->getLine()
in order to get the needed info and display it,
or am i missing something ?
The text was updated successfully, but these errors were encountered: