I am using the services module to do an xmlrpc node send from 1 site to another. Maybe very important but the services module has a node.save method which uses drupal_execute, but i have written a new node.save method which uses node_save() instead.
ok, that all being said, he's the issue.
I edit/create a node on one system and then using services (xmlrpc and node.save method) i "send" the node to the remote system. The xmlrpc middle transport is likely a red herring here as i am basically just doing a node_save().
So when the remote node is first created (i.e. there is no nid/vid in the node object prior to the node_save() call) - pathauto works correctly and creates a new url_alias.
However, when i do a node update:
- let's say change the node's title
- and send a node object which already has a nid/vid (matching a node on the remote system)
a new url_alias is created (matching the new title; as that is my pauto setting) BUT the old url_alias is not deleted (even though that is pauto setting on remote system).
so even though new alias created; old alias is first in table and the one that gets used on the site - plus, more importantly, it should have been deleted.
i have tried various combinations of setting/unsetting $node->path or $node->pathauto_perform_alias with no affect. and looking through code i don't see where the old alias (now numerous aliases after multiple tests) get deleted.
the only place in the code that i can see any aliases being deleted is in path.module
/**
* Set an aliased path for a given Drupal path, preventing duplicates.
*/
function path_set_alias($path = NULL, $alias = NULL, $pid = NULL) {
if ($path && !$alias) {
db_query("DELETE FROM {url_alias} WHERE src = '%s'", $path);
}
else if (!$path && $alias) {
db_query("DELETE FROM {url_alias} WHERE dst = '%s'", $alias);
}
but these conditions are never met so the numerous aliases are never deleted.
Is it possible that there is no self-healing sort of ability here? Possibly something was set up wrong intially and now that i have multiple aliases i can never set a new alias again?
Since no delete aliases code; perhaps all i can do is update THE existing alias; but once more than 1 exists this fails?
Or, and this is my hope, there is simply some other property of the node object that needs to be set to tell pauto to remove old aliases?
Comments
Comment #1
gregglesIt is true in general that Pathauto relies on the path module to delete aliases for nodes.
It is also true that Pathauto tries to delete aliases sometimes itself, but that can be hard to spot because the way to delete an alias is to call path_set_alias('node/'. $nid); and the way to update an alias is also to call path_set_alias.
Comment #2
liquidcms commentedhey greg, thanks.. i guess.. lol.. not sure what you are saying... i should perhaps move this to a path issue rather than a pathauto issue?
but, if nothing obvious that i am doing wrong, the other solution is simple... since i wrote a custom node.save method for my delivery service.. certainly no reason i can't simply add a delete alias portion to it.
thanks.
Comment #3
gregglesWell, the subtext of my response is that I have no idea what could be causing the problem ;) You've got a lot going on, you're using an old version of core and pathauto that I haven't thought about in at least a year...you're largely going to have to pin this one down yourself I just wanted to let you know how paths are deleted/updated and why your original search for "DELETE" might not have found what you expected.
Comment #4
dave reidComment #5
dave reidNo response, so I assume this means it has been solved, fixed, or no longer applies. If that is not the case, feel free to change this issues' status back to active.