Reproduce:

Add a node who's title will be calculated as longer than 225.
Press Save.
Drupal set message says it's been created with the full calculated title, but title of node will be 225 characters.

This could be bad if anything else is using the inaccurate title.

Node title enforces this by using '#size' on the title textfield.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

fago’s picture

Status: Needs review » Needs work

sounds good, could we add a comment to add it explaining why we need to do that?

fago’s picture

Status: Needs work » Fixed

I just added that in and committed it to all d5, d6 + added it into d7. thanks.

Status: Fixed » Closed (fixed)

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

Denes.Szabo’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
Status: Closed (fixed) » Needs review
FileSize
613 bytes

Sorry to open it, but I realized, the substr is not a solution for utf8 strings. I attached a patch, it uses truncate_utf8() to truncate the title to 255 character not substr().

Patch is for 7.x-1.x version.

Denes.Szabo’s picture

Patch for 6.x-1.x.

hdcoder’s picture

need change:

$node->title = substr($node->title, 0, 255);

to

$node->title = mb_substr($node->title, 0, 255);

is good work.

hefox’s picture

Status: Needs review » Needs work

drupal_substr?

andyceo’s picture

Status: Needs work » Needs review
FileSize
604 bytes
569 bytes
569 bytes

Please, use drupal_substr().

It was very hard to find a reason of PDO exception which was caused by this bug.

andypost’s picture

Priority: Minor » Major
Status: Needs review » Reviewed & tested by the community

This could cause a data-loss in titles so major

maximpodorov’s picture

Annoying bug. Please commit the simple patches.

maximpodorov’s picture

Priority: Major » Critical
anmolgoyal74’s picture

Assigned: Unassigned » anmolgoyal74
Issue summary: View changes

"truncate_title_utf8_aware-937086-4.patch" applies successfully.
And truncate_utf8() is better solution

gaurav.kapoor’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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