Since I’m making use of WordPress for this blog I figured I’d spend some time debugging it and send in the patches. To assist in tracking down the bugs I made a small addition to wp-config.php
:
function wp_error_handler(
$errno,
$errstr,
$errfile,
$errline
) {
error_log(
"WordPress Error: " .
"errno: {$errno} " .
"errstr: {$errstr} " .
"errfile: {$errfile} " .
"errline: {$errline} " .
var_export(debug_backtrace())
);
return(true);
}
set_error_handler('wp_error_handler');
It isn’t the most elegant logging mechanism, but it does make errors show pretty obviously. Most of the errors that have come up so far are use of variables that doesn’t exist. I’d recommend NOT using this on a live site.
One reply on “Debugging WordPress”
Thank you very much, this snippet has helped me pinpointed the problem in my client’s blog.
Turned out his database was corrupted, and tbale wp_options contained about 1,200,000 records. And I was wondering why his blog took forever to load 🙂 apache/error.log, mysql/mysql.log, mysql/mysql-slow-queries.log, etc – none of them had the clue that I needed.
Thanks again, it was most helpful !