When two users in Drupal are editing the same node (page, story, news, ...), only the results of the first one who saves his changes will be saved. The other one will get a nice message saying "This content has been modified by another user, changes cannot be saved.". This is what is called an optimistic locking strategy.
Let's get a closer look at this to fully understand what is going on here:
- User A hits 'Edit' on node 1234.
- User B hits 'Edit' on node 1234.
- User A is making some changes on the node form of 1234.
- User B is making some changes on the node form of 1234.
- User A hits the 'Save' button.
- Changes get saved.
- User B hits the 'Save' button.
- User B gets the message and his changes are not saved.
Why? Well, because otherwise User B would have overwritten the changes of User A.
If you want to know where this is done in the Drupal code, take a look at node_validate in the node module.
if (isset($node->nid) && (node_last_changed($node->nid) > $node->changed)) {
form_set_error('changed', t('This content has been modified by another user, changes cannot be saved.'));
}
If you want to alter this default behaviour, you can do so. You can download a module called Checkout (content locking) that brings pessimistic locking in Drupal. This means the node will be "locked" whenever a user is editing the node, so no other user can edit the node while the first one is doing his thing.
Comments
I think it goes like this:
- User A hits 'Edit' on node 1234.
- User B hits 'Edit' on node 1234.
- User A is making some changes on the node form of 1234.
- User B is making some changes on the node form of 1234.
- User A or B hits the 'Save' button.
- Changes get saved.
- The other user (still editing) hits the 'Save' button.
- The other user gets the message and his changes are not saved.
Wow. Thanks for the tip also see on http://www.servbit.com
I think it goes like this:
- User A hits 'Edit' on node 1234.
- User B hits 'Edit' on node 1234.
- User A is making some changes on the node form of 1234.
- User B is making some changes on the node form of 1234.
- User A or B hits the 'Save' button.
- Changes get saved.
- The other user (still editing) hits the 'Save' button.
- The other user gets the message and his changes are not saved.
Wow. Thanks for the tip...sites like this are part of the reason Drupal Trends are increasing...what a great community!
Post new comment