I am currently building a website where the menu hierarchy is determined by the url alias. In short I have one node that needs to be displayed with the correct active path in multiple places. I use a custom utility module to prebuild all the arbitrary url aliases.

The problem I noticed was that if the the pathauto generated record in {url_alias} did not have the highest PID value it returned the wrong alias. This is mainly because the look-up is done by source path (_pathauto_existing_alias_data()). Which is kind of strange because multiple aliases for IE a node would be useful behavior. But the other way around is kind of odd, because urls need to be unique.

I fixed this issue (for me) in the attached patch. It now does the lookup based on the pattern generated alias for that node thus always fetching the record generated by pathauto. This fixes the issue for me, because my patterns don't change. But this will most certainly break patterns using titles or some other values that are subject to change.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

joostpluijmers’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, pathauto-alias-update-lookup.patch, failed testing.

Michsk’s picture

I'm actually faceing issues with this as well, same setup as topic starter.

Michsk’s picture

The first thing that pops in my mind when i see your patch is that the checkbox for autogenerating the alias in the node edit form wont be checked.

joostpluijmers’s picture

I don't think this can be achieved without making the alias functionality more complex. Perhaps something for the Drupal 8 release?