Hi,
I'm not sure if this is a bug, but it seems, that in the following situation useless feed aliases are created:
Conditions
- Content type with automatic path pattern like [title]
- Node type that doesn't have required title, or a module that overrides the title e.g. in hook_nodeapi "presave" operation and can generate an empty title
- Create node with empty title
Result
- no alias for the node path itself is created (correct)
- an alias "/feed" for the nodes feed is created (incorrect): node/%/feed => /feed
I encountered this with the content_profile module, enhanced with cck fields. I do a lot of modification, amongst others I hide the nodes title from the user, give him separate first name and last name cck fields and concatenate them in hook_nodeapi "presave" operation. The concatenated value is put into $node->title, which is configured to be the base for the path alias.
I have set a pathauto pattern for the content type. And I automatically create the content profiles on registration, but at this moment the user has not yet had the possibility to enter his first or last name (the fields are not exposed in the registration form). That's why the title is empty. I could also make the first name and last name fields obligatory, but I would rather prefer to avoid this since it would introduce other issues for me.
I also have a setting for the feed alias for nodes which is "feed". Unluckily you cannot configure this for each content type separately, but only per module (user, taxonomy, node, and some other special ones, like faq if installed).
While the alias for the node itself is not generated I have multiple entries in the url_alias table with an alias of "/feed".
I checked the code and see, that it is completely logical that this feed alias is created. The node module supports feeds and The feed setting is set. Thats why in line 344 in pathauto.inc the function _pathauto_set_alias() is called with a non empty src argument "$src/$feedappend" and a non empty dst argument "$alias/feed". Since both are not empty they are incorrectly created.
I'm not sure if I understood the code correctly and would be glad if someone could have a look at this.
Also if somebody has a workaround for this kind of situation I would be glad to try it too. I find it possible as well that it is my code that is breaking the alias creation process, but from what I saw in the code I get the impression, that there should be a test in pathauto.inc wheather a non empty alias has been generated, so that only then a feed alias is created as well.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 715112-pathauto-empty-alias-no-feed-alias-D7.patch | 9.57 KB | dave reid |
Comments
Comment #1
fdambrosio commented+++
Comment #2
dave reidMakes sense. If the alias is not empty, generate a feed alias. If the alias is empty, we should still let the code execute but pass the empty alias to pathauto_set_alias() so that aliases are removed if desired.
Comment #3
dave reidFixed the one failure and committed to D7 and D6-2.
http://drupal.org/cvs?commit=397246
http://drupal.org/cvs?commit=397248