Can somebody shine a light into the difference of the two, in terms of their interaction with database when hook_node_insert()
is invoked? The documentation explains that
Note that when this hook is invoked, the changes have not yet been written to the database, because a database transaction is still in progress. The transaction is not finalized until the save operation is entirely completed and node_save() goes out of scope.
In fact, when I tried doing node_save($node)
, it will give me an error.
However, if I was doing it this way,
$nodeWrapper = entity_metadata_wrapper('node', node_load($node->nid));
$nodeWrapper->title->set(t("Saved by Entity Save"));
$nodeWrapper->save();
It works just fine. Has the new node being committed into the database after the entity->save()$nodeWrapper->save()
was executed?