I wrote a trigger to change the created time of a node to the current time as follows:

  $node->created = time();
  node_save($node);

When the trigger is executed, a warning is shown:

* user warning: Duplicate entry '163-117' for key 1 query: INSERT INTO term_node (nid, vid, tid) VALUES (115, 117, 163) in /rootdoc/modules/taxonomy/taxonomy.module on line 694.

Even though the warning is shown, data are saved as expected. What I want to do is to shut off the warning. How do I do that?
Am I using node_save($node) correctly?

I'm using Drupal 6.10, Workflow 6.x-1.1

thx!

Comments

ainigma32’s picture

Status: Active » Postponed (maintainer needs more info)

I'm not 100% sure but if you are using the core actions and triggers, I believe you can leave out the call to node_save all together.
That's because the $node object is passed by reference. It also explains the warning: you save the node (and some taxonomy terms) and then once all the actions have been invoked, the node module saves the node as well using the same taxonomy term information.

Please post back how that works out for you.

- Arie

xn2001’s picture

I'm not 100% sure but if you are using the core actions and triggers, I believe you can leave out the call to node_save all together.
That's because the $node object is passed by reference. It also explains the warning: you save the node (and some taxonomy terms) and then once all the actions have been invoked, the node module saves the node as well using the same taxonomy term information.

Please post back how that works out for you.

- Arie

No, you can't leave out the call to node_save all together. I tried with the core action "Publish post" and it needs "Save post" action which is basically doing what node_save() is doing.

xn2001’s picture

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

Close this issue. No longer need to use triggers, add my own button to the form.