I've struggled with this problem forever and after searching for about the 20th time for a quick fix I found this thread and decided to just hack a solution. I know this is a cardinal sin in the Drupal world but the offending function isn't hookable. Please don't kill me!
The problem appears to be something to do with errors that are created by an anonymous user. Watchdog entries reference the offending user. But if no UID is present the query finds nothing = empty error page. That's because the query performs an INNER JOIN on the user table, rather than a LEFT JOIN. So I went into the dblog.admin.inc file, found the dblog_event() function and added this just after the initial query on line 154:
if(!$result){
$result = db_query('SELECT w.*, u.name, u.uid FROM {watchdog} w LEFT JOIN {users} u ON w.uid = u.uid WHERE w.wid = :id', array(':id' => $id))->fetchObject();
drupal_set_message(t('For whatever reason the user information was not logged with the watchdog entry so the user information might not be accurate.'));
}
Or you could just change the original query from an INNER JOIN to a LEFT JOIN...or the total fail safe: remove the user information entirely from the query.
No, that fix doesn't use the DB API but neither does the original query. Maybe some kind soul can submit a patch to the core team since this is such a critical feature for many admins.
For the record I'm using a Postgres 9.2.6 database, Drupal 7.26, PHP 5.3.10, Apache 2.2.22.
Edit: So, after five years returning to this page every time Drupal released an update, I finally decided to follow the direction in the top response (rather than my quick hack). For those wondering, here's what I did.
- Created a new user with the username 'anonymous' and a fake email address. I set the new user as 'blocked'.
I don't have access to a nice database admin tool so I used the 'Execute PHP Code' option in the Development menu to run this little code snippet:
$query = db_query("UPDATE {users} SET uid = '0' WHERE name = 'anonymous'");
if($query == 1) {
drupal_set_message('User Updated');
}
Permanent problem solution. Yay.
error_reporting
anddisplay_errors
in php.ini