Using pathauto 7.x-1.0 and have a custom module that is calling pathauto_create_alias(). The existing default auto URL that was created when the node was created is not being removed and thus we get multiple URL's. The settings for URL Aliases is 'Create a new alias. Delete the old alias'

Tracing the code ... it executes the logic for PATHAUTO_UPDATE_ACTION_DELETE which then calls _pathauto_set_alias() and finally path_save() but don't see where the current URL is being deleted. The $path['pid'] is set but don't see it being deleted.

All is fine if in my module, I add code to delete the path as in pathauto_path_delete_all("node/{$node->nid}");

What am I missing or is this bug in core PATH or possibly path_auto?

Thanks!

Comments

dave reid’s picture

Status: Active » Postponed (maintainer needs more info)

This probably means that you're missing the valid $langcode parameter for pathauto_create_alias() and so _pathauto_existing_alias_data() fails to find the existing alias record.

Maybe the custom module should use something like pathauto_node_update_alias() instead so that logic of calling pathauto_create_alias() is handled for you?

blainelang’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)

Thanks Dave for your quick response and insight. I did some quick tests after you posted your response and was not getting the expected results with pathauto_node_update_alias either, but it was not until today that I could get back to it.

I can see what pathauto_node_update_alias() is doing to query and set the language property. In our case, the node language is also 'und' or LANGUAGE_NONE so I guess the same behaviour is occurring.

I've now added calls to pathauto_path_delete_all() for the node we have to update and it is now removing the previous aliases correctly. This custom module is used to correct the aliases for items added to the menu and then users drag those menu items to another location (handle if URL auto alias set or if manual alias set).