does dblog wanna log too early?

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'uid' cannot be null: INSERT INTO {watchdog} (uid, type, message, variables, severity, link, location, referer, hostname, timestamp) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9); Array ( [:db_insert_placeholder_0] => [:db_insert_placeholder_1] => php [:db_insert_placeholder_2] => %type: !message in %function (line %line of %file). [:db_insert_placeholder_3] => a:6:{s:5:"%type";s:6:"Notice";s:8:"!message";s:65:"Use of undefined constant REFERER_THEME - assumed 'REFERER_THEME'";s:9:"%function";s:14:"include_once()";s:5:"%file";s:78:"/home/xl/workspace/sanago/sites/all/modules/referer_theme/referer_theme.module";s:5:"%line";i:3;s:14:"severity_level";i:5;} [:db_insert_placeholder_4] => 5 [:db_insert_placeholder_5] => [:db_insert_placeholder_6] => http://default.sanago.localhost/admin/modules [:db_insert_placeholder_7] => http://default.sanago.localhost/admin/structure/types/manage/event/fields [:db_insert_placeholder_8] => 127.0.0.1 [:db_insert_placeholder_9] => 1303138071 ) in dblog_watchdog() (line 155 of /home/xl/workspace/sanago/modules/dblog/dblog.module).

Comments

damien tournoud’s picture

Status: Active » Closed (duplicate)

This is most likely already solved in 7.x-dev.

See #598586: watchdog() assumes $user is defined.

geek-merlin’s picture

Title: php error in hook_boot lets dblog throw "PDOException: Integrity constraint violation: Column 'uid' cannot be null" » syntax warning lets dblog throw "PDOException: Integrity constraint violation: Column 'uid' cannot be null"
Status: Closed (duplicate) » Active

wrong assumption.
it's about missing quotes in a const definition in a module (php5 is more picky with that).
nevertheless, dblog should not freak out then.

geek-merlin’s picture

Status: Active » Closed (duplicate)

ups, race condition...

dwees’s picture

Status: Closed (duplicate) » Active

I'm seeing the exact same error, and I don't see the duplicate case that resolves it. The fix from the issue in #1 did nothing to resolve this error on my site, which came up after upgrading to Drupal 7. I have tried clearing the cache, and verifying that the most recent database upgrade changes were in fact implemented in the database (which I believe was to add an index to the uid column in the watchdog table?).

Here's the dump of the error from my site, is this the same issue as above?

Notice: Undefined index: uid in dblog_watchdog() (line 148 of /home/content/24/8131124/html/modules/dblog/dblog.module).
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'uid' cannot be null: INSERT INTO {watchdog} (uid, type, message, variables, severity, link, location, referer, hostname, timestamp) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9); Array ( [:db_insert_placeholder_0] => [:db_insert_placeholder_1] => registry [:db_insert_placeholder_2] => %type: !message in %function (line %line of %file). [:db_insert_placeholder_3] => a:6:{s:5:"%type";s:12:"PDOException";s:8:"!message";s:965:"SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'FileTransferFTP-class' for key 1: INSERT INTO {registry} (name, type, filename, module, weight) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4), (:db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9); Array ( [:db_insert_placeholder_0] => FileTransferFTP [:db_insert_placeholder_1] => class [:db_insert_placeholder_2] => includes/includes/filetransfer/ftp.inc [:db_insert_placeholder_3] => [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => FileTransferFTPExtension [:db_insert_placeholder_6] => class [:db_insert_placeholder_7] => includes/includes/filetransfer/ftp.inc [:db_insert_placeholder_8] => [:db_insert_placeholder_9] => 0 ) ";s:9:"%function";s:22:"_registry_parse_file()";s:5:"%file";s:51:"/home/content/24/8131124/html/includes/registry.inc";s:5:"%line";i:179;s:14:"severity_level";i:3;} [:db_insert_placeholder_4] => 3 [:db_insert_placeholder_5] => [:db_insert_placeholder_6] => http://paperlessmath.com/admin_menu/flush-cache?token=z-QR4mZxQ0osw7Qjq9... [:db_insert_placeholder_7] => http://paperlessmath.com/ [:db_insert_placeholder_8] => 24.83.169.125 [:db_insert_placeholder_9] => 1336108877 ) in dblog_watchdog() (line 159 of /home/content/24/8131124/html/modules/dblog/dblog.module).

dwees’s picture

Status: Active » Closed (duplicate)

So my error is extremely strange simply because I did something completely strange - I apparently missed some files when upgrading my files. Setting this issue back to the most recent 'closed (duplicate)'.

adampv’s picture

(Drupal 7.32) I took out the following code : /var/www/vhosts/website.com/modules/dblog/dblog.module and it solved the problem:
But 2 days later the ibdata file got corrupted. I don't know if there is any relation between the 2 problems (!)

----------------
/**
* Implements hook_watchdog().
*
* Note: Some values may be truncated to meet database column size restrictions.
*/
function dblog_watchdog(array $log_entry) {
Database::getConnection('default', 'default')->insert('watchdog')
->fields(array(
'uid' => $log_entry['uid'],
'type' => substr($log_entry['type'], 0, 64),
'message' => $log_entry['message'],
'variables' => serialize($log_entry['variables']),
'severity' => $log_entry['severity'],
'link' => substr($log_entry['link'], 0, 255),
'location' => $log_entry['request_uri'],
'referer' => $log_entry['referer'],
'hostname' => substr($log_entry['ip'], 0, 128),
'timestamp' => $log_entry['timestamp'],
))
->execute();
}
---------------------