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
Updated 3 restaurants
I walked 3.1km in 29m25s
I walked 4.4km in 45m01s
I walked 5.4km in 55m28s
Updated a restaurant; Confirmed a hotel
I walked 6.3km in 1h12m59s
Paraphrasing opening keynote speaker at ConFoo: "Should we go back to the waterfall method of writing massive specs upfront to feed to AI coding agents?"
I walked 1.6km in 17m29s
I walked 2.1km in 17m44s
Updated a pub
I walked 2.6km in 26m41s
Merged pull request #1065
Comparison whether class is userland or internal used the wrong macro
PHP 8.6: zend_enum.h now mixes code with declarations
PHP 8.6: Argument names are now stored as zend_strings
Updated a bench and a waste_basket
I walked 8.3km in 1h25m37s
Created a recycling
I walked 10.5km in 1h46m57s
An interesting journey in story form, showing how English changed over time.
https://www.deadlanguagesociety.com/p/how-far-back-in-time-understand-english
A much better writer than I is summing up perfectly why I have such disdain for Generative AI/LLMs.
https://jonn.substack.com/p/so-why-do-i-feel-so-angry-about-this
Created a waste_basket; Updated a waste_basket; Deleted a bench
Created a bench; Updated 7 benches and a gate; Deleted 2 benches and a gate
Created 10 benches and 2 waste_baskets; Updated an information


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