The functionality introduced by the patch discussed in this thread is not working in 4.7 Head. This means that the following sequence will result in data loss:

Alice opens a node for editing
  Bob opens the same node for editing
  Bob saves his changes
Alice saves her changes to the node, overwriting Bob's changes

When Alice tries to save her edits, she should be presented with this error message from line 1581 of node.module:
form_set_error('changed', t('This content has been modified by another user; changes cannot be saved.'));

I've set priority normal, as any data loss should be recoverable through the revisions system. Please clue me if this is not appropriate.

My environment:
Drupal: 4.70 Head (CVS)
node.module: 1.603
PHP: 5.1
MySQL: 5.0.18-max (non-strict mode)
OS: Mac OS X 10.4

CommentFileSizeAuthor
#3 node_edit_protect.patch1.49 KBhunmonk
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Egon Bianchet’s picture

Version: 4.7.0-beta4 » 4.7.0
hunmonk’s picture

Version: 4.7.0 » x.y.z

this is still a problem in current HEAD.

hunmonk’s picture

FileSize
1.49 KB

$node->changed was being passed internally as a value, per the FAPI conversion. this breaks this functionality. so two things need to happen to fix this:

  1. changed has to be sent to the client as a hidden field, so we can mark for them the last time the node was edited
  2. we have to examine $_POST upon submission of the node form, not $form_values, because when the form is submitted, it's rebuilt, and the new changed time is what appears in $form_values, not the original changed time that we need for comparison.

i know using $_POST is frowned upon, but i think it's warranted in this case, as we're merely peeking at it for data, and not saving that data anywhere.

attached patch has been tested as functioning, and corrects the problem.

hunmonk’s picture

Assigned: Unassigned » hunmonk
Status: Active » Needs review
chx’s picture

Status: Needs review » Reviewed & tested by the community

rule of $_POST is: use it to compare but never display or store it. This is kept.

As you are using #value and not #default_value even if the user changes to something foul the hidden field, there is no harm because the actual value of the form can't change. Though it'll show in $_POST and you compare against that. So far, so good.

Restores lost functionality without the mere possibility of boring sechole. RTBC.

Gerhard Killesreiter’s picture

applied to 4.7

drumm’s picture

Status: Reviewed & tested by the community » Fixed

Committed to HEAD.

Anonymous’s picture

Status: Fixed » Closed (fixed)