If the email has a subject that is more than 64 characters, the comment is not created, and the following error appears:

Data too long for column 'subject' at row 1 query: INSERT INTO comments .....  in ...\modules\comment\comment.module on line 764.

The comments column subject is varchar(64), while the node title is varchar(255). Perhaps this should be addressed by the mailcomment_extras filtering. Thanks for any help.

Roman

Comments

intu.cz’s picture

I did two things, in a very makeshift way, as a quick workaround:

in mailcomment.module after line 273 inserted:
$message->subject = mb_substr($message->subject, 0, 60)."...";
so that messages have a trimmed subject in the first place. After this I discovered that email clients add Re: and whatever else to the subject so I went to the mailhandler.retrieve.inc and inserted
$header->subject = mb_substr($header->subject, 0, 55)."...";
after line 372.

Hopefully, this should be taken into account in a better way: if the email is a comment, than subject can have only 64 chars.

BarisW’s picture

Version: 6.x-1.x-dev » 7.x-2.x-dev

You can also work around this without having to patch the module, using hook_comment_insert:

<?php
/**
 * Implements hook_comment_insert() to trim the subject if needed.
 */
function MYMODULE_comment_insert($comment) {
  if (strlen($comment->subject) > 55) {
    $comment->subject = truncate_utf8(strip_tags($comment_text), 55, TRUE);
  }
}
?>

As this problem still occurs in 7.x, I've changed the version.

BarisW’s picture

Status: Active » Closed (duplicate)

Hmm, my code above does not seem to work. The problem actually lies in feeds_comment_processor, not in Mail Comment. I've created an issue in that module and attached a patch. Marking this issue as duplicate.