Skip to main content
14 events
when toggle format what by license comment
Mar 14, 2014 at 20:07 vote accept rwaery
Mar 10, 2014 at 21:58 answer added TwoD timeline score: 2
Feb 3, 2014 at 2:32 answer added berliner timeline score: 1
Feb 3, 2014 at 2:17 comment added berliner Technically you can't. It is clearly stated that the node is not yet finally saved in the database at the time when hook_node_insert is invoked. Practically though, I'm not aware of any other hook based solution to react on a node being created, and usually there should be no reason for a transaction rollback. The note in the docs is also mostly about not tying to reload node data from the database, as it's not yet written.
Feb 3, 2014 at 2:07 comment added rwaery @berliner, thanks for looking into this. Exactly my thoughts. The error was about integrity constraint violation. Initially I had the same questions as the other posters on hook_node_insert() [doc page] (api.drupal.org/api/drupal/modules!node!node.api.php/function/…), on whether or not to trust the nid contains in $node object while still inside hook_node_insert() scope. Say, I wanted to trigger an email with link to the new node, and trigger it from hook_node_insert() can I be sure that the node is already committed to database?
Feb 3, 2014 at 1:57 history edited rwaery CC BY-SA 3.0
added 8 characters in body
Feb 3, 2014 at 1:56 comment added berliner @rwaery It seems strange to me to call node_save() inside a hook_node_insert(), as this hook is triggered from node_save(). Smells bad. If you just want to alter the data before it get's saved, use hook_node_presave().
Feb 3, 2014 at 1:53 comment added berliner @rwaery What error message do you get?
Feb 3, 2014 at 1:51 history edited rwaery CC BY-SA 3.0
deleted 5 characters in body
Feb 3, 2014 at 1:33 history tweeted twitter.com/#!/StackDrupal/status/430152034776776704
Feb 2, 2014 at 23:29 answer added m1n0 timeline score: 0
Feb 2, 2014 at 23:29 comment added mpdonadio I edited the title. The code you posted is about entity_metadata_wrapper(). entity_save() is different, and I think this matches you question better.
Feb 2, 2014 at 23:28 history edited mpdonadio CC BY-SA 3.0
Little cleanup.
Feb 2, 2014 at 23:15 history asked rwaery CC BY-SA 3.0