Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Current if two or more users working at node/add/story, if one saves, others' autosave will be lost.
Comment | File | Size | Author |
---|---|---|---|
#6 | uid_on_node_add.patch | 1.22 KB | liquidcms |
Comments
Comment #1
jcisio CreditAttribution: jcisio commentedPump to major. For medium to large sites, most users spending time to add new nodes, not modify the old ones.
Comment #2
liquidcms CreditAttribution: liquidcms commentedare these anonymous users? as the autosaved form is keyed with uid so doesn't make sense that this should be happening.
Comment #3
jcisio CreditAttribution: jcisio commentedNo, there is no uid in form_id. The form_id is something like this: blog_node_form or story_node_form. The problem is at line 186-194.
Comment #4
liquidcms CreditAttribution: liquidcms commentednope, not what i meant. when the form is stored in the db - it is saved with the user's uid. and when the form values are pulled up later (when that user goes to re-edit) this code is used:
which again uses his uid in the KEY to get which entry is pulled from the db.
So the db stores both the path to the node edit AND the uid. So path is typically enough if they are editting an existing node (path = node/123/edit) but yes, it isn't enough on its own when the user is editing a new node for first time as the path is simply node/add/type.. which is why it is also keyed with the uid.
so basically you would have in the db, if 2 people editing,
node/add/type, 5
node/add/type, 23
and we would be able to distinguish.
the only place this falls down is if you have anonymous users editing as they all have uid = 0. Only way to fix that would be to key off there IP address - although not completely sure how well that would work if multiple users are all behind same router (i.e. at the same company) as they may all present the same IP address.
Comment #5
liquidcms CreditAttribution: liquidcms commentedahh... yup.. i see now.
yes, the code you refer to will cause a problem but was required as mentioned in the comments
// we remove ALL edits for that page (not just the users) to avoid:
// - user1 asaves but doesnt submit
// - user2 edits same node and submits
// - user1 comes back to edit -> user1 SHOULD lose edits since user2 has precedence
but this will break in your case.
likely i need to qualify the delete here with the /add path type. I'll take a look later this afternoon and post a patch.
Comment #6
liquidcms CreditAttribution: liquidcms commentedany chance you can try this patch?
Comment #7
jcisio CreditAttribution: jcisio commentedI think, instead of checking the path, we should check the nid in the form (think that the node form can be populated by Ajax or be embedded in any page).
Edit: I didn't see the patch above. Will try it later. However the comment is still valid ;)
Comment #8
liquidcms CreditAttribution: liquidcms commentedyea, except this is when saving the node.. we don't have the form at that point..
but i think you may be right about the form being embedded - although was never the intent of this module; possibly easy to check if $node->nid exists at that point. i'll need to test this out but seems like it should be ok - will test later today and provide a new patch if works