The module does not seem to check the length of the subject line. This is a problem, because the subject column in the database only supports strings of 64 characters and thus, Drupal throws an error when importing mails via e-mail.

SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'subject' at row 1

comment_save does a trim, but only when the subject is not set.

The patch fixes this.

CommentFileSizeAuthor
trim-subject-line.patch742 bytesBarisW

Comments

BarisW’s picture

Status: Active » Needs review
Yuri’s picture

Yes, I confirm that the error is now gone, when that patch is applied.

danepowell’s picture

Title: Trim subject if it is too long » SQL error if subject too long
Status: Needs review » Fixed

I don't know how the original patch ever worked- it uses the non-existent variable $comment_text. It also clobbers the subject if it already exists.

I committed a variation of this:
http://drupalcode.org/project/feeds_comment_processor.git/commit/503da5d

Status: Fixed » Closed (fixed)

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

rob230’s picture

Sorry if this is a stupid question, but why have you chosen 29 as the truncation length? The subject field of comments has a limit of 64 characters. If I update to the latest version that has this commit, will my comments' subjects be limited to 29 characters?

danepowell’s picture

@BarisW would have to answer why 29 is the magic number. I didn't really think about it- I just adapted his patch. You might want to open a new issue if your subjects are being truncated.

BarisW’s picture

The subject column can contain 32 characters. As we append three dots I chose to limit the length to 29 (+3 = 32).

rob230’s picture

If you look at comment_schema(), the subject field is 64 characters:

      'subject' => array(
        'type' => 'varchar',
        'length' => 64,
        'not null' => TRUE,
        'default' => '',
        'description' => 'The comment title.',
      ),

Also in the database:

mysql> DESCRIBE comment;
+----------+---------------------+------+-----+---------+----------------+
| Field    | Type                | Null | Key | Default | Extra          |
+----------+---------------------+------+-----+---------+----------------+
| cid      | int(11)             | NO   | PRI | NULL    | auto_increment |
| pid      | int(11)             | NO   | MUL | 0       |                |
| nid      | int(11)             | NO   | MUL | 0       |                |
| uid      | int(11)             | NO   | MUL | 0       |                |
| subject  | varchar(64)         | NO   |     |         |                |
| hostname | varchar(128)        | NO   |     |         |                |
| created  | int(11)             | NO   | MUL | 0       |                |
| changed  | int(11)             | NO   |     | 0       |                |
| status   | tinyint(3) unsigned | NO   |     | 1       |                |
| thread   | varchar(255)        | NO   |     | NULL    |                |
| name     | varchar(60)         | YES  |     | NULL    |                |
| mail     | varchar(64)         | YES  |     | NULL    |                |
| homepage | varchar(255)        | YES  |     | NULL    |                |
| language | varchar(12)         | NO   |     |         |                |
+----------+---------------------+------+-----+---------+----------------+
14 rows in set (0.01 sec)

You also said 64 in the original post. I'm not sure where 32 has come from?

I have tried limiting it to 64 and it worked fine. 32 seems a bit short to me:

1234567890123456789012

Of course, it will work because 32 is less than 64 but you are limiting people unnecessarily to half of what they could have.

rob230’s picture

Also I think truncate_utf8() handles the three dots for you and still keeps the length you specify.

danepowell’s picture

Thanks for the investigating Rob230- could you please open a new issue for increasing the limit, and post a patch there if you're able?

rob230’s picture