1

Me and a colleague had a D7 problem to handle, $_SESSION were being lost for anonymous users. Because this is all happening on a staging server in a corporate environnment, devel module has been ripped out in preparation for the push to production. My colleague starts inserting var_dumps() in a forms validate function, but the results don't show to screen.

He figures the validation is not being called, but I tell him about how Drupal suppresses output during rendering, I have experienced this many times. Adding a die in the validate function confirmed that the function was in fact being executed, except the question remains -> why / how is output suppressed when echoing / var_dumping in functions?

Debugging with var_dump is probably not the most recommended or effective method, I just want to know what it is that prevents ouptput.

2 Answers 2

5

Usually the var_dump() works but gets hidden below the theme. This is because theme rendering comes last.

I could go into it more, but basically just install Devel and use dpm() for your variable dumps. It prints them in a Drupal-style message. You'll love it.

0

you'll see it if you exit execution:

var_dump( $your_variable );
exit();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.