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.
After enabling the module, if I try to upload / remove an image, it displays error 'The page you are editing could not be locked automatically. Please lock the page to make sure other people cannot accidentally overwrite your changes' (see attached screenshot). The content can be saved and locking is working fine though. This is on latest version of Drupal (7.54).
Comment | File | Size | Author |
---|---|---|---|
#5 | fix_error_messages_on_ajax-2866669-5.patch | 814 bytes | pacproduct |
#3 | content_lock screenshot.jpg | 232.53 KB | Rudi Teschner |
error-on-uploading-image.png | 83.83 KB | Ashok Negi |
Comments
Comment #2
Ashok Negi CreditAttribution: Ashok Negi at Srijan | A Material+ Company commentedComment #3
Rudi Teschner CreditAttribution: Rudi Teschner commentedI get the message on unexpected places as well.
Even though the node itself has been successfully locked, once I open a previously closed table paragraph, the module error message appears.
Does it, by any chance, try to lock all loaded entitys when you are in the backend?
Comment #4
pacproduct CreditAttribution: pacproduct commentedSeems to me like this happens whenever an AJAX callback is issued to refresh a part of the form which gets rebuilt, which triggers
content_lock_node_form_handler()
for acquiring a lock on the node edit form.That fails because there's no token provided by the AJAX call, and because of that an error message is returned by the AJAX call, and displayed on the page where the area is refreshed.
I'm not quite sure my approach is the right one but here is a patch suggestion attached.
It solves the issue in our scenario, but I'm wondering if it doesn't bypass some of this module's security layers somehow, as it now skips locking in this particular case:
* Current user already has a lock on the node's form being processed
* The form is being rebuilt ($form_state['rebuild'] == TRUE)
Comment #5
pacproduct CreditAttribution: pacproduct commentedSame patch, simply moved the code further up in the function, as it did not need to run that late.
Comment #6
Rudi Teschner CreditAttribution: Rudi Teschner commentedThe patch works for me. The error when I open paragraphs and the callback is triggered does not cause the "content could not be locked" error anymore.
About the security implications ... my understanding is (please correct me if I'm wrong about it) that since the user already has a lock on a node, the module doesnt need to lock the node anew just because a form rebuild was triggered.
Comment #7
Simon Georges CreditAttribution: Simon Georges at Makina Corpus commentedComment #8
szeidler CreditAttribution: szeidler at Ramsalt Lab commentedPatch #5 is also successfully solving the issue for me. It happened with every ajax related form updates, like image upload, paragraphs, inline_entity_forms and co. So it should affect a lot of users.
Comment #9
Simon Georges CreditAttribution: Simon Georges at Makina Corpus commentedComment #10
Rudi Teschner CreditAttribution: Rudi Teschner commentedUpdate: I've noticed recently that the last patch causes paragraphs to be saved when node edit is cancelled.
Comment #11
Rudi Teschner CreditAttribution: Rudi Teschner commentedComment #12
Rudi Teschner CreditAttribution: Rudi Teschner commentedThough I have absolutely no clue why this happens at all. Can someone else verify this behaviour?