Is there a way to force an alias update via the API?

For example, in my module I add taxonomy terms to a node. But the url() is not immediately returning the path alias. (I suspect there is another bug elsewhere).
So I want to test/bypass the potential bug - and force an alias update on the node.

Comments

nextpulse’s picture

I tried this:

pathauto_node_operations_update(array($node->nid));

But doesn't seem to work.

Must be another way.

greggles’s picture

That seems like the best way to do it to me, or copying the code in that module...

So, I suggest you debug that a bit more.

nextpulse’s picture

I am note sure if this a bug. Heres the scenario:

My automated setting for the node is:

mynodetype/[term-raw]/[title-raw]

Now when I do the following to the node:

taxonomy_node_save($node, array($term->tid));

The url('node/nid') gives:

mynodetype/title-of-the-node

It does not see the taxonomy.
Now when edit the content, the taxonomy is there. Only when I do a save on the content page, do I see the url being updated.

I did also try pathauto_node_operations_update(array($node->nid)); after the taxonomy_node_save() - but no effect.

bug? or am I doing something wrong?

greggles’s picture

Probably the node has been cached somewhere? By node_load perhaps?

greggles’s picture

Status: Active » Fixed

Since it works properly when edited normally, I'd say that it's a bug in your code.

Maybe look at http://drupal.org/node/178506 which should fire the code in a more "manual like" manner.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.