After installing the browscap module, I kept getting error messages as below:
Duplicate entry 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.' for key 1 query: INSERT INTO browscap_statistics (parent,counter,is_crawler) VALUES('Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)', 1, 0) in ******\includes\database.mysql.inc on line 66.
Looks like this is caused by the length of the parent field in the browscap_statistics table - it's set at only 64 characters. This means that
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)
gets truncated to
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.
and Drupal keeps trying to add new entries for the untruncated version - which get truncated once again, resulting in the error above.
Setting the parent field to varchar(255) fixes this (until we get an even longer browser ID code, I guess) - not sure if the parent field in the browscap table needs to be lengthened as well, but I've done so just to be on the safe side...
Axel Bruns (snurb.info)
Comments
Comment #1
mikeryanYep, I set it to 64 based on the maximum parent value actually in the browscap data, but by defaulting to the string provided by the browser when there's no match in browscap I risk going above that. I'll both change the field definition to 255, and truncate the string at 255 before storing, to prevent this.
Thanks for the report!
Comment #2
mikeryanFixed this a while ago, but never committed it... It's in 4.6 now. Existing installations need to modify the parent field to 255 chars.
Comment #3
mikeryan