I have a question related to _node_save_revision function in drupal 7. I just want to know how I can get the new revision ID after saving a revision using this function

It is mentioned in the documentation here.

The resulting revision ID is available afterward in $node->vid.

But how does this happen? Where is the new revision ID assigned to the node object?

1 Answer 1


drupal_write_record handles that.

vid is the primary key on the node_revision table, as declared in node_schema, and drupal_write_record knows that because it introspects the schema when writing the record.

From there it just takes the ID returned from the database query, and populates the correct property on the object that was passed in. In this case, that's the vid property on the node object.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.