We installed IP address manager on a site a few days ago, and today when I looked at the logs, I'm seeing this every cron run:
PDOException: SQLSTATE[22003]: Numeric value out of range: 7 ERROR: value "9223372036854775807" is out of range for type integer LINE 1: ...t' AND message = '@type: added %title.' AND wid < '922337203... ^: SELECT wid, hostname, link FROM {watchdog} WHERE type = 'content' AND message = :msg AND wid < :backlog_nodes ORDER BY wid DESC LIMIT 20 OFFSET 0; Array ( [:msg] => @type: added %title. [:backlog_nodes] => 9223372036854775807 ) in ip_backlog_nodes() (line 359 of /home/site1/public_html/sites/all/modules/ip/ip.module).
The problem is in this code:
$ip_backlog_nodes = variable_get('ip_backlog_nodes', PHP_INT_MAX);
if ($ip_backlog_nodes) {
$result = db_query_range(
"SELECT wid, hostname, link" .
" FROM {watchdog}" .
" WHERE type = 'content'" .
" AND message = :msg" .
" AND wid < :backlog_nodes" .
" ORDER BY wid DESC",
0,
20,
array(
':msg' => '@type: added %title.',
':backlog_nodes' => $ip_backlog_nodes,
)
);
The issue is the use of PHP_INT_MAX as a default for the ip_backlog_nodes Drupal variable. The value of PHP_INT_MAX changes depending on whether PHP is compiled for 32-bit or a 64-bit machine, while the size of a SQL int field is fixed at 32 bits. When running on 64 bits, PHP_INT_MAX will be too large for the wid field. The max value for a 32-bit integer (2147483647) should be used here.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | ip-Do_not_use_PHP_INT_MAX-2496535-1.patch | 1.2 KB | ben coleman |
Comments
Comment #1
ben coleman commentedComment #2
ben coleman commentedAttached is a patch to fix the above problem.
Comment #3
gedur commentedThis is solved in 7.x-2.x branch, as the variable is not needed (the process is now been executed in batch).
Comment #5
ben coleman commented