Hello,
function pathauto_alias_uniquify is passing wrong params to truncate_utf8. It's pretty much a typo, but could cause not desired/expected behaviour. It could lead to strings that are not truncated in word boundaries, leading to a bigger strings than expected.

The TRUE value that supposed to be passed to truncate_utf8 it's being passed to drupal_srtlen instead.

Here is the code of that line (watch for TRUE param):

$alias = truncate_utf8($original_alias, $maxlength - drupal_strlen($unique_suffix, TRUE)) . $unique_suffix;

Reviews are very welcome

Comments

tuwebo’s picture

Issue summary: View changes

Added better documentation

dave reid’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests
Parent issue: » #2305515: Plan for Pathauto 7.x-1.3 release

This shows we're lacking some test coverage.

tuwebo’s picture

Hi @Dave Reid,
Thanks for taking a look at this issue.
I'm debugging a little more, and I just noticed that pathauto_clean_token_values is calling pathauto_cleanstring which is already calling truncate_utf8 with right params.

So, if we are using a pattern like [node:title] the issue could come from:
1) Create a node with a title which will be truncated to a 99 chars, title can be something like this
thisisatesttocheckwetherornot pathautoisusingwordboundary fortruncatingstrbasedonmaxlengthof100char

2) Create a node with same title, then the resulting alias right now will have this value
thisisatesttocheckwetherornot-pathautoisusingwordboundary-fortruncatingstrbasedonmaxlengthof100cha-0
Which is wrong because truncate_utf8 is not using the right params.

The result should be something like:
thisisatesttocheckwetherornot-pathautoisusingwordboundary-0.

I'll try to create a test for it.

tuwebo’s picture

Status: Needs work » Needs review
StatusFileSize
new1.77 KB

Hi,
I've rerolled the patch adding a test for it.

tuwebo’s picture

Issue summary: View changes

Added better documentation.

dave reid’s picture

StatusFileSize
new5.05 KB
new5.66 KB

Shortened up the test cases.

The last submitted patch, 9: 2423077-test-only.patch, failed testing.

  • Dave Reid committed 794c45c on 7.x-1.x
    Issue #2423077 by Dave Reid, TuWebO: Fixed wrong parameters passed to...

  • Dave Reid committed 708aa97 on 8.x-1.x
    Issue #2423077 by Dave Reid, TuWebO: Fixed wrong parameters passed to...

  • Dave Reid committed d587082 on 6.x-2.x
    Issue #2423077 by Dave Reid, TuWebO: Fixed wrong parameters passed to...
dave reid’s picture

Status: Needs review » Fixed

Committed #9 to 7.x-1.x.

Status: Fixed » Closed (fixed)

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