Problem/Motivation
When fetching email at ~/admin/config/support/clients/[clid]/fetch I get the following error
PDOException: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'subject' at row 1: INSERT INTO {comment} (pid, nid, uid, subject, hostname, created, changed, status, thread, name, mail, homepage, language) 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, :db_insert_placeholder_10, :db_insert_placeholder_11, :db_insert_placeholder_12); Array ( [:db_insert_placeholder_0] => 0 [:db_insert_placeholder_1] => 21 [:db_insert_placeholder_2] => 16 [:db_insert_placeholder_3] => Xxxxxxx Xxx Xxxxxx :: new comment on What Xxxxxxx Means to Xxxxxxxxx [:db_insert_placeholder_4] => xxx.xxx.xxx.xxx [:db_insert_placeholder_5] => 1315728157 [:db_insert_placeholder_6] => 1315728157 [:db_insert_placeholder_7] => 1 [:db_insert_placeholder_8] => 01/ [:db_insert_placeholder_9] => admin@xxxxx.org [:db_insert_placeholder_10] => admin@xxxxx.org [:db_insert_placeholder_11] => [:db_insert_placeholder_12] => und ) in drupal_write_record() (line 6868 of ~/includes/common.inc).
Note - edited for privacy, but the edits maintain the character count of the "subject" field.
It seems like the subject field length (68 characters in this situation) is exceeding the length of the database column, which is currently stored as varchar(64)
Proposed resolution
Adding a call to substr to truncate the string before it is sent to the database.
Inserting the following at line 3367 of support.module
$message['subject'] = substr($message['subject'], 0, 64);
It might be nicer to add an elipsis to the end of a truncated message subject to indicate that the alteration was performed.
Comments
Comment #1
bdragon commentedThe one with the ellipsis is truncate_utf8().
Also, I think it might be better to change it specifically for comments, because nodes can have 255 characters in the title...
Something like this maybe?
Comment #2
jeremy commentedLooks good!
Comment #3
bdragon commentedFixed on 6.x and 7.x.
http://drupalcode.org/project/support.git/commit/d8dafb50cb3539157bf14cf...
http://drupalcode.org/project/support.git/commit/36574d0757da1ce69947331...