-
Notifications
You must be signed in to change notification settings - Fork 777
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
file_get_contents warnings suppression #567
Comments
No, it doesn't make sense at all. You should handle your exceptions yourself. |
@garak I agree that you should handle the exceptions ourselves, which we do. But the default behaviour of file_get_contents is to also send a warning to stdout (and such output might break the response to the client) |
I get my errors into Sentry, so there's a way to do it. |
you get the errors in Sentry, but the output to the end customer will be broken, despite we catch the error.
but due to the missing warning suppression the output sent back to the customer is corrupted (not a valid json anymore) due to PHP printing the warning in the output. Is it more clear like this? |
The error output should never be active in production |
I agree @garak. It's only active in our production environment used by the internal staff |
And so in the end the one to blame for your wrong output is you, not this library. |
If you're happy with this answer and feel good to have defended a position, Yes, you're right. |
I'm afraid that adding sarcasm and passive-aggressive messages won't help that much to defend your position (which is already hard to defend, in any case) |
Hi @garak The library output (not mine!) is caused by using the wrong approach to make requests, and is sending unmanaged output in case of warnings. e.g. this would not have happened if you were using curl. You're saying that it's our fault because in production we should keep error_display to no, but the principle is wrong in any case. The errors should be catched and thrown at the upper level. You can't justify that it's correct like this because it's not. A library should not write output to stdout/stderr |
Mine was not sarcasm, really. |
I've not said that you should hide errors. You should suppress the errors sent to the output (if you want to continue use file_get_contents), catch the error after the file_get_contents and throw the exception |
You can already suppress the error output by correctly configuring your environment. |
Currently file_get_contents is called like this
$response = file_get_contents($this->siteVerifyUrl, false, $context);
Could it make sense to use the error suppression with @ to avoid random errors going to stdout?
We capture few errors per week like
Failed to open stream: HTTP request failed! HTTP/1.1 503 Service Unavailable
The text was updated successfully, but these errors were encountered: