It is quite easy to exceed the the watchdog referer and location field length of 128.

The problem especielly with pgsql is that it generates an error, not just truncate the content like MySQL does.

1. For all databases I would suggest changing the limit to 255 (which is, at least for MySQL, the real limit).
2. More imporant: Add substrs to watchdog().

I would make a patch for the second but I fear I lack knowledge of update_***() for the first.

CommentFileSizeAuthor
#1 drupal-head-referer-29814.diff1.07 KBCvbge
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Cvbge’s picture

Status: Active » Needs review
FileSize
1.07 KB

This patch cuts referer to 128 characters before inserting into db, not tested.
About field length - don't know what's right approach.

Thomas Ilsche’s picture

About field length - don't know what's right approach

Is there ANY reason to use VARCHAR(128)?

MySQL stores them always using one length byte plus the actual string, resulting in a maximum VARCHAR(255), there is no reason to use a lower n?

pgSQL afaik always uses four length bytes with a physical limit of 1 GB, If I am not mistake text / VARCHAR without any length specifier could be used without any disadvantages. So why not use that? I think thats more easy and comfortable than truncating the string.

bl4h’s picture

is it ok to set varchar 255? Im worried theres a good reason for not having it set that way.
This bug is extremely annoying!!!! Especially if you have php display warnings on

Warning: Data too long for column 'referer' at row 1 query: INSERT INTO watchdog (uid, type, message, severity, link, location, referer, hostname, timestamp) VALUES (1, 'php', 'Data too long for column 'referer' at row 1\nquery: INSERT INTO watchdog (uid, type, message, severity, link, location, referer, hostname, timestamp) VALUES (1, 'page not found', '<em>genie</em> not found.', 1, '', '/genie', 'http://forums.xxxxxxxx.com/dir-app/bbcard/profile_center.asp?webtag=tc-xxxxxms&cType=2&uName=xxxxxxxxx&dMode=0&eBtn=0&uid=1376049847', '68.82.xxx.xx', 1144858305) in C:\\Program Files\\Apache Group\\Apache2\\htdocs\\includes\\database.mysql.inc on line 120.', 2, '', '/genie', 'http://forums.xxxxxxxx.com/dir-app/bbcard/profile_center.asp?webtag=tc-xxxxxxs&cType=2&uName=xx in C:\Program Files\Apache Group\Apache2\htdocs\includes\database.mysql.inc on line 120
Cvbge’s picture

Status: Needs review » Fixed

I believe this was fixed in cvs version. All columns in watchdog table except for type and hostname columns (which contain limited data and don't need to be changed) are "text" type now.

Anonymous’s picture

Status: Fixed » Closed (fixed)