Greetings!
I have run into a situation where the node object seems to lose its properties when node.module invokes module _insert hooks. Here is a case:
0. some.module is a module that adds a node and a related taxonomy term.
1. User submits new content from some.module
2. some.module processes the user input through _validate, then (assuming valid input) _insert.
3. _insert then saves the taxonomy term a la:
$edit["name"] = $node->title;
$edit["vid"] = variable_get("some_vid", 0);
$edit["synonyms"] = $node->synonyms;
$edit["description"] = $node->body;
$edit = taxonomy_save_term($edit);
$node->taxonomy = array($edit["tid"]);
4. A trace of $node->taxonomy reveals that it is an array containing the desired tid.
5. The node object is then, presumably, passed on to taxonomy.module.
6. A trace of $node->taxonomy in taxonomy.module reveals that it is empty.
Now, is this simply because the node object is not passed by reference? If so, any ideas on how I could create the functionality desribed in the case without altering the drupal core? I gave thought to using node_submit() or taxonomy_node_save(), but, from my understanding, those would only result in multiple DB queries; the latter creates duplicate nodes and both methods result in duplicate calls to taxonomy_node_save() with an empty $node->taxonomy (resulting in empty taxonomy references for the inserted node) due to the behavior of node.module's call to some.module's _insert hook.
Or am I completely off my rocker?
Cheers!
-t-