I pointed out some trouble I was having with project_release tokens to greggles in IRC, and he called it a pathauto bug. ;) pathauto_cleanstring() is only called on tokens, not the finished alias. So, if you have a trailing separator (e.g. from using a token that only conditionally has a value), the trailing separator is left in the resulting alias if that token happens to be empty for a given node.
Patch coming soon to add pathauto_clean_alias(), which (at greggles's scope-creep request invokes hook_pathauto_clean_alias(), too). ;) Stay tuned.
| Comment | File | Size | Author |
|---|---|---|---|
| #30 | 545216-pathauto-fix-cleanalias.patch | 15.13 KB | dave reid |
| #29 | 545216-pathauto-fix-cleanalias.patch | 16.33 KB | dave reid |
| #28 | 545216-pathauto-fix-cleanalias.patch | 14.19 KB | dave reid |
| #23 | 545216-pathauto-fix-cleanalias-D7.patch | 12.16 KB | dave reid |
| #17 | 545216-pathauto-fix-cleanalias-D7.patch | 11.27 KB | dave reid |
Comments
Comment #1
dwwNote, since both pathauto_cleanstring() and pathauto_clean_alias() want to strip leading/trailing separators and collapse duplicates, I moved that code into a private helper function that's shared by both.
Also note that pathauto_cleanstring() should be renamed to pathauto_clean_string(), but that's out of scope for this issue. ;)
Comment #2
gregglesI'm inclined to commit this but leave it here for review for a few days.
Regarding the new hook and why scope creep is ok: It will allow us to say "oh, you want to do crazy? yeah, do it yourself based on hooks." Instead of just arguing over what we are/aren't going to do.
Comment #3
dwwI'm all in favor of hooks. I just didn't want anyone to accuse me of slipping in a new feature with my bug unprovoked. ;)
Comment #4
linl commentedHi,
I'd run into a similar issue and was about to add a feature request/patch.
My alias pattern is something like this:
1/[field_name-raw]-[field_optional1-raw]-[field_optional2-raw]
I had been putting whitespace in the pattern, instead of the separator, and then had a small patch to pathauto.inc to trim and replace whitespace in the complete alias.
Now I've tested the patch in #1 instead and it works well for me. :)
Comment #5
gregglesThanks dww for this patch.
Applied to 6.x-1.x http://drupal.org/cvs?commit=327030
@dww Any chance you can port this to 7.x?
Comment #6
dwwThanks for committing! Sorry, no chance for me to port this anytime in the near future, no. :( My plate is already completely overflowing...
Comment #7
dave reidD7 patch attached for review.
Comment #8
dave reidRevised and committed to 7.x-1.x and 6.x-2.x as well.
Something I'm not exactly sure on is why the lowercasing is in a function meant to remove separators. Also, we need to document this in pathauto.api.php.
Comment #9
dave reidThis inconsistency needs to be fixed before the next release on any branch.
Comment #10
dave reidI'm really not happy with the hook that was added here.
Comment #12
dave reidComment #13
dave reidComment #15
dave reidComment #16
dave reidComment #17
dave reidWith a test creating a parent term with the alias 'My Crazy/Alias' and a child term with the pattern [term:parent:path]/[term:name], so it would end up as 'My Crazy/Alias/child-term'
Comment #19
dave reidGreat, we found a core bug: #870528: taxonomy_get_parents(), taxonomy_get_children(), and taxonomy_get_tree() do not return a full term objects.
Comment #20
dave reidStill hoping that core bug gets fixed shortly, but don't think I can do much until then. :/
Comment #21
dave reid#17: 545216-pathauto-fix-cleanalias-D7.patch queued for re-testing.
Comment #23
dave reidLet's try that without the debugging line and a stupid logic error in the test...
Comment #25
dave reid#23: 545216-pathauto-fix-cleanalias-D7.patch queued for re-testing.
Comment #26
dave reidDid a contrib-wide search for implementations of hook_pathauto_clean_alias and found none. Committing shortly.
Comment #27
dave reidCommitted to 7.x-1.x CVS. http://drupal.org/cvs?commit=404100
Comment #28
dave reidComment #29
dave reidTry this again with PHP 5.3 fixes...
Comment #30
dave reidComment #31
dave reidSimpletest for D6 is getting really irritating with not installing dependencies. This passes absolutely fine locally.
Committed to 6.x-2.x: http://drupal.org/cvs?commit=404400
Comment #32
dave reidCommitted to 6.x-1.x as well after manual testing: http://drupal.org/cvs?commit=404428
Comment #34
cyberderf commentedSorted ?