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).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Ashok Negi created an issue. See original summary.

Ashok Negi’s picture

Issue summary: View changes
Rudi Teschner’s picture

FileSize
232.53 KB

I 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?

pacproduct’s picture

Version: 7.x-3.0-beta1 » 7.x-3.x-dev
Status: Active » Needs review
FileSize
940 bytes

Seems 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)

pacproduct’s picture

Same patch, simply moved the code further up in the function, as it did not need to run that late.

Rudi Teschner’s picture

The 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.

Simon Georges’s picture

szeidler’s picture

Patch #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.

Simon Georges’s picture

Status: Needs review » Reviewed & tested by the community
Rudi Teschner’s picture

Update: I've noticed recently that the last patch causes paragraphs to be saved when node edit is cancelled.

Rudi Teschner’s picture

Status: Reviewed & tested by the community » Needs review
Rudi Teschner’s picture

Though I have absolutely no clue why this happens at all. Can someone else verify this behaviour?