Quick-and-Dirty Debugging

Quick-and-Dirty Debugging

Add Comment
Bookmark/Search this post with:
Delicious Delicious
Digg Digg
StumbleUpon StumbleUpon
Facebook Facebook
Google Google
Yahoo Yahoo
Technorati Technorati
Saturday, April 28, 2007
By admin
So you’re coding along, developing your site, minding your own business, when you load a page you see some totally vague, obscure error message such as:

warning: Invalid argument supplied for foreach() in /modules/node/node.module on line 504.
Where do you even start debugging something like that?

Well, you could start with looking at line 504 of node.module…

    foreach ($param as $key => $value) {
Uh, yeah. That’s helpful.

If you were astute, you might also observe that line 504 is inside of the node_load() function. So that narrows it down to… only one of the 80,000 places node_load() might be called from one of your core or contributed modules or themes. Ugh…

You could decide to get all fancy, and install an IDE like Komodo, Eclipse, or Zend, and use their real-time debugging features to step through the code one line at a time to figure out what’s happening. It’s pretty time-consuming, and it takes up lots of resources on your machine, but it’ll probably help you nail it down if you are observing carefully.

Or! You can debug the quick and dirty way! Read on to find out how!

Leave a Reply

Your email address will not be published. Required fields are marked *