I was given a problem: the (somewhat usual) error message showed up
Warning: Invalid argument supplied for foreach() in element_children() (line 6396 of common.inc).. Trying to debug it with the usual print-and-see is entirely and totally hopeless. If you print just
element_children? You get
picture. If you try to print the backtrace? It's impossibly big. One hope is printing the backtrace with
DEBUG_BACKTRACE_IGNORE_ARGS and then manually opening up every step in the rather big backtrace. Or you can set a conditional breakpoint on the problematic line with
!is_array($elements) as a condition and immediately have access to the backtrace in a very nice structured/collapsed format where you can see the parent, grandparent etc render arrays, reach every caller with one click and eventually find this in a template:
<?php foreach ($content as $key => $item): ?>
<?php print render($item); ?>
I have worked for years without a debugger -- finding this without is really frustrating and slow. Finding it with one is a matter of minutes. And PhpStorm debugger is literally zero config.
Commenting on this Story is closed.