minor bug to report! The error about happenes if you are trying to leave a comment for a node that has a title more than 64 characters.

It is a little bit confusing for users leaving comments. I suggested fix is to allow the module to automatically trip any characters that are passed the 64 character limit on the comment subject.

You can test the following bug at the following URL http://www.compshack.com/forum/peoplesoft/peoplesoft-technical/strange-i...

Please let me know what you think?

CommentFileSizeAuthor
#5 subject_truncate.patch884 bytesahoeben

Comments

ahoeben’s picture

Thanks, I'll look in to this.

sgdev’s picture

I'm having the same problems on my site. I've had several users tell me they couldn't post comments on particular blog entries. Then I realized the reason why is the blog entries had really long titles, and therefore the default comment subject was longer than 64 characters.

No error message is presented to the user, it just returns to the page to fill out the comment again. Would be better if a really long title is truncated to be something like "Re: A really long title, a really long title, a really long title..."

ahoeben’s picture

I'm sorry, I have been busy with other things lately. A patch is fairly trivial, but I've had no time for it yet.

arhak’s picture

is this an issue of this module?
shouldn't be the comment.module which reports a validation error?
besides, this module might take care of not proposing long subject, but I think it should be truncated by comment.module, or at least reported as a validation error so this module would have to check for it first.

ahoeben’s picture

StatusFileSize
new884 bytes

Yes, it's an issue of this module. The subject title is generated programmatically, and the created value can not always be used as is. The module should be smarter than that.

Attached is a patch, that needs some testing before I create new packages (for 4.7.x, 5.x and 6.x).

ahoeben’s picture

Assigned: Unassigned » ahoeben
Status: Active » Needs review
arhak’s picture

well, yeah, this module should truncate, but.. doesn't have comment module to complain about validation?
I'm asking if there is also a flaw on comment module?

jaydub’s picture

Works in testing for me.

jaydub’s picture

Have to make a small adjustment to account for the ' ...' dots added as
a result of the 4th parameter to the truncate_utf8() call

    // comment subjects can not be longer than 64 characters
    $subject = truncate_utf8($subject, 64, TRUE, TRUE);

should be

    // comment subjects can not be longer than 64 characters
    $subject = truncate_utf8($subject, 60, TRUE, TRUE);

alternatively you can drop the use of the ' ...' dots and set back to 64

ahoeben’s picture

truncate_utf8 takes care of that automatically:
http://api.drupal.org/api/function/truncate_utf8

jaydub’s picture

That's not true in the d5 version of truncate_utf8() although is the case in d6+

After applying the patch I got a further bug report from someone who hit 65 chars so I thought it might be the dots. For the sake of discussion the string was this:

Subway stations to be lengthened, transfer channels to be widened, trains to be lenthend to 8 carriages

Adding the prefix 'Re: ' the string is now:

Re: Subway stations to be lengthened, transfer channels to be widened, trains to be lenthend to 8 carriages

When running that string through the truncate_utf8() function I get a resulting string of:

Re: Subway stations to be lengthened, transfer channels to be ...

which happens to be 65 chars and thus still throws an error.

So for d5 versions, you should set the length to 60 to be safe.

ahoeben’s picture

You are correct, thanks for testing

CompShack’s picture

Would this be committed to the d6 branch as well?

arhak’s picture

wold this have something to do with this particular bug?
line 244, unicode.inc

  if ($wordsafe) {
    $string = drupal_substr($string, 0, $len + 1); // leave one more character
arhak’s picture

wold this have something to do with this particular bug?
line 244, unicode.inc

  if ($wordsafe) {
    $string = drupal_substr($string, 0, $len + 1); // leave one more character
arhak’s picture

for a better appreciation
unicode.inc

function truncate_utf8($string, $len, $wordsafe = FALSE, $dots = FALSE) {

  if (drupal_strlen($string) <= $len) {
    return $string;
  }

  if ($dots) {
    $len -= 4;
  }

  if ($wordsafe) {
    $string = drupal_substr($string, 0, $len + 1); // leave one more character
    ...
ahoeben’s picture

Title: Subject cannot be longer than 64 characters but is currently 89 characters long. » Subject cannot be longer than 64 characters
Status: Needs review » Fixed

Fixed in 1.4 releases for D4.7 - D6. New release packages should appear within 24 ours.

Status: Fixed » Closed (fixed)

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