Many times when I start a hook_preprocess_hook, I start by printing the $vars object. I can do this by dpm()'ing, dsm()'ing, kint()'ing etc. The problem is that all of these functions print $vars in an expanded fashion and bring my computer to its knees. dd() works incredibly well in just about every other thing I do inside drupal, but for some reason dd() just WSOD's inside a preprocess.

Is there anything like dd() (i.e. prints arrays/objects in a collapsed fashion) that can be used inside a preprocess?

I'm aware of XDebug, but I'm wondering if there is something as simple as install module -> use function like devel/dd() works in other drupal applications.

  • This is strange, dd() works fine inside a hook_preprocess_node, but WSODs inside a hook_preprocess_paragraph__paragraphType – plambre Jul 1 '19 at 17:56
  • No functionality to it, but “array_keys($vars)” will show the top level array keys. – Prestosaurus Jul 1 '19 at 17:56
  • Install devel_kint and use ksm( $var). Don't click on the + items, click on the type link.. e.g. array... this limits the open to one level and is much faster. Another trick is to start with a ksm(array_keys($var)) and then drill down to the item your interested in, e.g. ksm($var['content']) and the like. – CG Monroe Jul 1 '19 at 17:59
  • Have you tried to look in the apache error logs to find out what causes the WSOD? Maybe its using to much memory, abd then you can just fix it by setting the memory limit to -1 in your php.ini file, or maybe something completely different causes the error. – user72672 Jul 2 '19 at 8:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.