In drupal5, you should call hook_node_submit() and hook_nodeapi('submit') before node_save(). that will assure that any group info gets saved (for example). In d6 this is not needed since those submit hooks became hook_nodeapi(pre_save) and that happens from within node_save(). drupal_execute is also a valid way. the node_load() is a little expensive but this is a very clean way to proceed. if it is working for you, i would proceed like this. On Sat, Mar 8, 2008 at 10:53 AM, Novák Áron <aron@novaak.net> wrote:
Hi!
While the development of FeedAPI, i faced with a problem. FeedAPI has to create nodes programmatically, i believed that this is a really easy thing to do, feedapi now works like this: $node->data1 = "foo"; $node->data2 = "bar"; node_object_prepare($node); // this is about the default values node_save($node);
But I got a report that this is not a good way to do: http://drupal.org/node/196273 Summary: "node_object_prepare() and node_prepare() functions are meant to simulate the demonstration of a node" And some users, who use FeedAPI + 3rd party modules together, really experience bugs around node creation / handling: http://drupal.org/node/195105 (summary: the core forum module uses form_alter to pass taxonomy-like data. And this data is lost now.)
Can you suggest me a perfect way to handle this problem? mustafau (http://drupal.org/user/207559) suggested to use drupal_execute($form_id, $form_values), but in this case, i had another problem: drupal_execute has no useful return value and $node structure remains unaltered, so i had to do a node_load after this, which is quite expensive.
Thanks,
Aron Novak