Contributing Advent 20: Xdebug halting on error
After Rob came up with the idea for xdebug_print_function_stack() from episode 17 he filed another issue. This new issue request thats a new setting to be added to Xdebug that allows users to decide whether notices and warnings should be treated as (fatal) errors. It's very much like GCC's -Werror setting which converts every compiler warning into an error that aborts the compilation process. The article for episode 4 talks a bit more about GCC's flags.
But as we are talking about PHP and Xdebug here, lets focus on this new feature that I added. xdebug.halt_level is a setting that allows you to configure a mask. This mask determines which notices get converted to errors. Right now, you can configure notices and warnings that are generated by PHP, and notices and warnings that you generate yourself (by means of trigger_error()). For example, to convert the warning of strlen() (without arguments) to an error, you would do:
<?php
ini_set('xdebug.halt_level', E_WARNING);
strlen();
?>
Which will then result in the showing of the error message, and the abortion of the script. echo "Hi!\n"; will not be executed.
The new setting is a bit mask, so to convert all notices and warnings into errors for all applications, you can set this in php.ini:
xdebug.halt_level=E_WARNING|E_NOTICE|E_USER_WARNING|E_USER_NOTICE
And that means, that errors created by trigger_error() also cause the termination of the script.
This new feature is going to be part of Xdebug 2.3. Stay tuned!
Comments
Ok this is good and it's probably a bit late to comment, but instead of halting it would be nice to make it stop (not error/exit) like a breakpoint. Or are we talking about the same thing? :)
Thanks for a great product!
Andrew
@Andrew: Xdebug already supports that through an exception breakpoint on Notice. Not many IDEs support that though.
Life Line
In times like this, it's actually fairly useful to be able to read a fair amount of Danish.
Merge branch 'v2022'
Go with 2022.16
Merge branch 'v2022'
Merge branch 'v2022'
Go with 2022.15
Do a shallow clone
Merge branch 'v2022'
Update data to 2025c
Merge branch 'v2022'
Update script for current PHP versions
I hold the domains phpvikinger.{org,net,com}, which are expiring in three months.
I am not going to renew them as I have no use for them any more.
If you're interested, let me know? It'll cost you just the normal registration fees.
I walked 4.8km in 44m52s
I walked 2.1km in 20m46s
I walked 5.8km in 1h12m05s
Robin
They usually never sit still long enough close by for a good photo. But this little bird was perched on this branch for several minutes letting lots of people take photos of it. When I started taking photos, it looked directly at me and my camera — it was clearly posing!
I walked 10.5km in 1h48m41s
I hiked 16.2km in 3h23m19s
Updated a restaurant
Updated a restaurant
I walked 8.7km in 1h25m51s
Merged pull request #1056
Add metadata header to CSV file
RE: https://phpc.social/@Tideways/115859809842500892


Shortlink
This article has a short URL available: https://drck.me/adv1320-aff