The E-Commerce and Organic Groups modules provide special URLs for their content types. These URLs are not aliases and so do not appear in the list of URL aliases. When generating index aliases, the Pathauto module only checks to see if the alias exists. As a result, the real URLs for products and groups no longer work.
I can think of three possible solutions. First, prevent the Pathauto module from generating URLs that already exist. Second, add the option to ignore aliases when real URLs exist to the path module. Third, make either the Pathauto module or the path module add aliases for all existing URLs to the alias list.
I would prefer the first option as a long term solution. My temporary solution is to add real URLs to the alias list by hand.
| Comment | File | Size | Author |
|---|---|---|---|
| #14 | pa_protect_callbacks.patch | 1.58 KB | greggles |
| #3 | pathauto.module_5.patch | 4.66 KB | RobRoy |
Comments
Comment #1
RobRoy commentedI'm getting this too. Have a View set up a /foo and want all foo content types to be at /foo/[date]/[title] but the index aliases keep creating a /foo index alias.
I'm brainstorming ways to get around this as right now we just have this:
Thoughts?
Comment #2
gregglesDarren wrote "prevent the Pathauto module generating URLs that already exist"
Is there a list of existing URLs somewhere?
Also, I'm not sure that preventing is the right behavior. I can conceive of users wanting to over-write those URLs on purpose (I know I have done this at times).
Another possible solution would be to have the "Create index aliases" on a per pattern basis. So, in RobRoy's example you would set the pattern you want for content types /foo/[date]/[title] and then you would turn OFF index aliases for that content type. This makes the interface and functioning more complex, but gives the user more control.
Comment #3
RobRoy commentedCheck out this patch. It checks to see if the requested destination alias is an existing callback.
So 'blog' is a callback and won't allow an alias, but 'blog/1' is allowed. I opted for the former to be a bit less restrictive. I'm looking for some input though.
Comment #4
RobRoy commentedAnd this is a bug IMO.
Comment #5
RobRoy commentedOn second thought, this seems like a bug with path.module since that is what ultimately is generated these bogus paths. Should we really be allowing users to create an alias of 'admin' for 'node/1'? I think not.
Comment #6
greggles@RobRoy - any feeling on how to handle the situation where the user WANTS to over-write the "blog" page?
If we implement your patch it will just be a month before someone comes back and says "PathAuto won't let me over-ride the blog/ page and I really want to do that"
Comment #7
RobRoy commentedYeah, I think we could have a setting in there for "advanced users only" to toggle this behavior (or, allow a user submitted list of URLs NOT to alias?). I'd like to get some more input on this first, before making a solid patch. (Sorry about the lang stuff in there, for some reason I can't get that clean.)
Comment #8
tormu commentedYeah same problem here with Event-module.. Whenever an event is created it overwrites the /event/-path, and that particular path is pretty crucial since it provides the view for the calendar table.
Could be great if there would just be something like "ignore these paths" or something and then the user could write "event" there, besides the available user, blog and admin.
Comment #9
greggles@jari - that sounds pretty reasonable.
One problem with the solutions that put the control in the user's hands (including my own proposed solution) is that they require the user to know lots of stuff that is not common knowledge. I'm starting to think that a combination of robroy's solution and jari's solution would be good. E.g. display a list of existing callback menu items to the user each time the settings/pathauto page shows and request that the user confirm items into a textarea list of items that pathauto won't over-write.
Comment #10
RobRoy commentedShould this go to the path.module? We already don't allow duplicates in path_set_alias() and I think we should not allow certain aliases there as well.
What about allowing modules or the menu.module to register callbacks and whether they can be overwritten or not. For example, when system_menu() registers the 'admin' callback, could we specify an 'overwritable' => TRUE (defaults to FALSE)? Kinda clunkey, just throwing that out there.
But by default, I think we should *not* allow aliases to overwrite existing callbacks, but allow overwriting either in an advanced settings page or with some sort of hook_path_alter() or whatever.
Or, maybe in pathauto we don't allow overwriting but you can manually overwrite an alias in admin > url aliases.
Eh?
Comment #11
darren ohOnly allowing manual overwriting sounds sensible to me. The point of the pathauto module is to supply paths that don't yet exist.
Comment #12
gregglesYeah, I really think that we should prevent multiple aliases. I know that pathauto has an option for "create a second alias leaving the current alias alone" but that seems like a bad idea on multiple levels...
This seems like something that belongs in core node/path modules...Hopefully I'll get around to doing something about it.
Comment #13
darren ohI would like to see this patch reviewed to see if it needs work. The purpose of the patch is to add a callback check in addition to the existing alias check. It seems just as essential to check for existing callbacks as it is to check for existing aliases (which the module already does).
Comment #14
gregglesReview:
Other than that, it worked fine in my tests.
About the "@todo: This menu call might not be all-inclusive"
If you look at menu_get_menu and _menu_build it seems that the $user is mostly for cache and items in the $menu['visible'] portions of the returned array. I think the callbacks should be complete.
http://api.drupal.org/api/4.7/function/menu_get_menu
http://api.drupal.org/api/4.7/function/_menu_build
Also, I've documented the message so that people can easily find how to override. - http://drupal.org/node/83957
Attached is a cleaned up version of the patch. If you agree with it then I'll commit it.
Comment #15
darren ohI enthusiastically agree. Thanks for all the thought and effort.
Comment #16
Stefan Nagtegaal commentedI'm not very fund of this piece of code, and also the sentence itself strikes me:
It should be something like:
Setting status to 'code needs work'
Comment #17
darren ohWhy don't we handle callbacks the same way as existing aliases (as I would have suggested to start with had I been more familiar with Drupal then)?
Comment #18
greggles@Darren - can you be more explicit? Callbacks work differently than "normal" aliases so we have to treat them differently to some extent. But there is certainly an argument for consistency in certain areas - especially in the user interface.
@Stefan - pathauto currently says "Ignoring alias ..." in several places. I like the current sentence because it is consistent. Do you propose that we change it to your style in the other places where we use "Ignoring alias..."?
Thanks for the review.
Comment #19
darren ohMy original solution was to add callbacks to the URL alias list manually to prevent them from being overwritten. Pathauto seems to respect existing aliases. I understand that callbacks and aliases are different. What I meant by suggesting that we treat them the same was this: Pathauto should behave the same whether it's URL conflicts with an existing alias or with an existing callback.
Comment #20
gregglesDarren - I think we're headed there.
Comment #21
gregglesI talked about this more with Steef in IRC and we agreed that we shouldn't hold back this patch based upon his dislike for the wording.
So, I created a new issue to track the wording changes and have committed the patch to HEAD and 4.7.
Thanks everyone!
Comment #22
(not verified) commented