http://www.flickr.com/photos/hhoyer/2859038799/
minimalmedia.com/debugging-drupal DrupalCamp Ohio December 13, 2013 David Trainer Minimal Media @minimalmedia minimalmedia.com/debugging-drupal
What's Debugging?
What we won't cover Interactive debugging and profiling tools like Xdebug, NetBeans, xhprof xdebug.org github.com/facebook/xhprof They are too platform-specific
Who does debugging? Not just developers Not just code Not just errors Anyone who ever needs to dig into the system to figure out how something works Sometimes requires teamwork Debugging doesn't necessarily mean development You don't need to be writing code in order to experience a need to dig into the system and figure out how stuff works Any situation where the expected behavior doesn't match the expected behavior Importance of reproducing/replicating the issue: Sales/PMs take note: You can't really start debugging until you can reproduce the problem Should end with “The result was x, when I expected to see y”
When do we need to do debugging? When the behavior of a system does not match the expected behavior Need complete knowledge of both, in order to study the gap between them What if you're not the one encountering the behavior?
“It's not coming up”
“It's not coming up”
“It's not coming up”
“It's not coming up”
Reproducibility Need a good description of the steps to reproduce Test by inducing the problem behavior, while observing conditions inside the system On a complex issue, you can't start debugging until you can reproduce it http://drupal.org/node/952034
How to think What's Debugging? 1. Gather information 2. Form a hypothesis; devise a test 3. Test 4. goto 1 What's Debugging?
Gather Information
Tools and Resources api.drupal.org Chrome Developer tools, Firebug Drush Devel devel_demo Coder curl find
Logging Understand how different parts of the system report problems PHP Logging php.ini display_errors log_errors error_log Drupal dblog Syslog /var/log/syslog YMMV Understand how different parts of the system report problems
Understand how different pieces of the architecture fit together Instrumentation Understanding what Drupal actually does when it builds a page Bootstrap Menu callback Examine response headers using Chrome and curl Understand how different pieces of the architecture fit together
Know how to use the tools to reveal what's going on inside Instrumentation Understanding node hooks Using dpm() you can peer inside the node object during every phase You can use dpm() in the theme layer too ddebug_backtrace() Hack drupal_set_message() Know how to use the tools to reveal what's going on inside
Strategies Be prepared Dev environment Access to live environment Tools necessary to create an entire copy of your site, quickly Divide and conquer, process of elimination Turn off your theme Turn off modules
Common Problems WSOD: http://drupal.org/node/158043 Caching Reverse proxy cache Page cache Block cache Permissions Look out for field permissions Cron Performance related Make a list
Uncommon Problems Teaser trimming Menu cache
Thanks Robert Ristroph http://2011.drupalcampatlanta.com/session/debugging-techniques-drupal- and-lamp/index.html Angie Byron http://www.lullabot.com/articles/quick-and-dirty-debugging Randy Fay http://www.randyfay.com/topics/debugging Morten Wulff http://drupal.org/user/7118
minimalmedia.com/debugging-drupal Q&A @minimalmedia minimalmedia.com/debugging-drupal