Hello,

I am using the revisioning module.

I created a page with a page title "Information resources", menu title of the same and under "URL path settings", I unticked 'Automatic alias' (which would generate the path 'information-resources' with my set up), and set a custom path of 'information'.

Whenever I edit this page using the node edit form and create a new revision pathauto keeps my custom path, but whenever my custom module uses node_save and creates a new revision like this:

		$node->revision = 1;
		$node->revision_moderation = 1; 
		$node->is_pending = 1; 
		$node->log = 'New revision as node deadline has come up for editing;
		node_save($node);

the custom path is not preserved either for the new revision or the old (published) revision - instead when I look at it in the edit form again the 'Automatic alias' box is ticked.

I have solved this using path_set_alias after saving the node:

		$node->revision = 1;
		$node->revision_moderation = 1; 
		$node->is_pending = 1; 
		$node->log = 'New revision as node deadline has come up for editing;
		$path = $node->path;
		node_save($node);
		path_set_alias('node/' . $node->nid, $path);

I've noticed that this only affects nodes which have menu entries. Pages without menu entries keep their custom URL alias. I think this is a bug, non-automatically generated URL aliases should always be preserved based on this documentation http://drupal.org/node/1167612. I think (but I'm not sure) that this might have something to do with a recent set of module updates I've done. I'm reluctant to update pathauto to 6.x.2 to see if this bug still exists there, but possibly it's worth looking into.

Comments

dave reid’s picture

Status: Active » Postponed (maintainer needs more info)

Is there anything in $node->menu when you are saving it?

dave reid’s picture

Also, if you are saving a node manually, you need to specify $node->pathauto_perform_alias = FALSE; to stop Pathauto from doing its work. Or install Pathauto persistant state.

rukaya’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

I just tested it using $node->pathauto_perform_alias = FALSE; and it's absolutely fine, so I was just missing that bit of information, thanks! I will add it as a comment to that bit of documentation. Cheers.