I joined this crazy company as a Site Administrator. Now I did some changes to my db configurations which have impacted the PHP scripts execution.
Strange part is PHP scripts just die. They don't throw any errors. When I went inside the scripts I realized they have used @ error suppression directive. Now the whole codebase is million of lines spread over thousands of file and don't want to run something like sed to replace '@'.
But '@' has made debugging impossible for me. Its like developers are closing their eyes and find vision dark are saying its night.
Is there a way I can undo error suppression done by '@' and let php log directive handle it. Touching the codebase is not an option. I am looking forward for a way where I can do this by modifying the php configuration or adding few lines in the bootstrap file.
Suppress specific warnings for Visual C# or F# Or, select the project node and press Alt+Enter. Choose Build, and go to the Errors and warnings subsection. In the Suppress warnings or Suppress specific warnings box, specify the error codes of the warnings that you want to suppress, separated by semicolons.
Suppression of Last Error By default, runtime checking suppresses the most recent error to prevent repeated reports of the same error.
You can use traceback() to locate where the last error occurred. Usually it will point you to a call you make in your function. Then I typically put browser() at that point, run the function again and see what is going wrong. The number means how deep we are in the nested functions.
The quickest way to display all php errors and warnings is to add these lines to your PHP code file: ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL);
If you have Xdebug installed and enabled (in development, you should) then you can set the xdebug.scream configuration option, which disables the @-operator.
Alternatively, the scream PECL extension also disables the @-operator (and that's all it does).
Basically you install the extension then set the scream.enabled
ini setting to true/on.
Muted errors are still visible for the handler installed via set_error_handler
. So you can just add something like this to your bootstrap file:
set_error_handler(function ($errno, $errstr, $errfile, $errline) {
echo "$errstr at $errfile($errline)\n";
});
or, better,
set_error_handler(function ($errno, $errstr, $errfile, $errline) {
throw new ErrorException($errstr, $errno, 1, $errfile, $errline);
});
which also would display the stack.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With