Pathauto menu token duplicated for a menu added in hook_node_insert I have a content type using the following pathauto-token pattern: [node:menupath]/[node:title], I added manually a menu using a hook_node_insert (see my previous question: creating a menu in a hook_node_insert()).
When the node is saved it doesn't have the [node:menupath] token in the URL, just the [node:title]. I decided to generate the path using pathauto API and this code:
$options = array(
  'language' =&gt; isset($node-&gt;language) ? $node-&gt;language : LANGUAGE_NONE,
);
module_load_include('inc', 'pathauto');
$uri = entity_uri('node', $node);
$path = pathauto_create_alias('node', 'insert', $uri['path'], 
  array('node' =&gt; $node), $node-&gt;type, $options['language']);

Doing this lead to duplicates in the url_alias table, the [node:menupath]/[node:title] alias being created first then the title.
I tried to add a $node-&gt;pathauto_perform_alias = FALSE; in a presave, but seems to be inefective.
Also I tried to set my new path in the hook_node_insert but had no success:
$path = pathauto_create_alias('node', 'insert', //...
$node-&gt;path = $path;

My code doesn't feel right, what would be the normal way to avoid duplicate and getting my pattern to work ?
Thanks
I finally moved the insertion of my menu in hook_node_presave() and then pathauto worked normally.