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

bdragon’s picture

Status: Active » Needs review
StatusFileSize
new1.08 KB

The 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?

jeremy’s picture

Status: Needs review » Reviewed & tested by the community

Looks good!

bdragon’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.