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
Comment #1
tuwebo commentedAdded better documentation
Comment #2
dave reidThis shows we're lacking some test coverage.
Comment #3
tuwebo commentedHi @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 fortruncatingstrbasedonmaxlengthof100char2) Create a node with same title, then the resulting alias right now will have this value
thisisatesttocheckwetherornot-pathautoisusingwordboundary-fortruncatingstrbasedonmaxlengthof100cha-0Which 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.
Comment #4
tuwebo commentedHi,
I've rerolled the patch adding a test for it.
Comment #5
tuwebo commentedAdded better documentation.
Comment #9
dave reidShortened up the test cases.
Comment #14
dave reidCommitted #9 to 7.x-1.x.