2

I have not had a need for this, but another (home built PEAR) CMS I support for a client uses locking to prevent two users from being able to edit a piece of content at the same time. It can be irritating but could prevent loss of work.

I suppose if you have multiple site editors it could be invaluable.

Is it necessary? Is the module content lock a viable option?

1
  • Any feedback about my answer? Commented Feb 8, 2018 at 13:25

4 Answers 4

5

I believe this is already implemented to some degree. If two users are editing the same piece of content, and one submits changes, the other user will receive this message when trying to do the same:

The content on this page has either been modified by another user, or you have already submitted modifications using this form. As a result, your changes cannot be saved.

It happens in the node_validate() function in case you're interested in checking out the code.

5
  • 1
    What a super simple check! I suppose you implement locks when there is a higher chance of concurrent editing perhaps like stackexchange.
    – Duncanmoo
    Commented Jul 11, 2012 at 18:38
  • 1
    I'd say so, yeah. The content lock module looks good, but it does place responsibility on the users to unlock the posts when they're done. Call me paranoid but I try to give users as little responsibility as is physically possible...they're less likely to break things that way!
    – Clive
    Commented Jul 11, 2012 at 18:45
  • Is this module superfluous then? :- drupal.org/project/content_lock Commented Dec 16, 2013 at 11:00
  • @therobyouknow "Superflous" might be a bit strong. It's complementary really
    – Clive
    Commented Dec 16, 2013 at 11:02
  • 1
    At the moment, Content lock is no longer maintained and has a XSS vulnerabilty: drupal.org/project/content_lock
    – Oscar M.
    Commented Feb 26, 2014 at 18:38
1

Below is a possible solution to address this question, which implements an edit-in-progress (EIP) feature using the Flag module, combined with the Rules module to get it to work. Read on for more details ...

Step 1: Create an edit-in-progress flag

Create a global (not user specific) flag, and say you name (label) it edit-in-progress flag (='EIP' for short). The purpose of this flag is like so:

  • If this flag is turned on for a node, it means "somebody is editing this node, so do not allow any additional edit sessions for this node to be started".
  • If this flag is not turned on for a node, it means "the node is available for authorized users to start editing it".

Step 2: Create a rule to disallow edit if the EIP flag is set

Create a rule to disallow edit of a node if the EIP flag for a node is already set. To recognize a request to start an edit session for a node, use an URL like node/xyz/edit (with xyz = nid of the node).

Refer to my answer to the question about "How to restrict access to a node via node/12 and allow access via a path like content/sometitle?", which contains a rule that is pretty close to what's needed for this rule here:

  • Use the same Rules Event, i.e. "Drupal is initializing" (you want to catch this edit event via Rules BEFORE the edit session actually allowed to be started!).

  • Slightly adapt the regular expression, by adding /edit to it.

  • Add an extra condition to verify if the EIP-flag for this node is ALREADY turned on (which indicates some other edit session for this node was started already).

  • Adapt the Rules Action to (a) issue an appropriate message (that some other edit session is already started) and (b) redirect the user to whatever other path that fits your needs (e.g: just node/xzy).

Step 3: Create a rule to SET the EIP flag when an edit starts

Create a rule to SET the EIP flag for a node whenever an authorized user requests to start an edit session for a node. To recognize such request, use an URL like node/xyz/edit (with xyz = nid of the node).

Refer to my answer mentioned in Step 2, which contains a rule that is pretty close to what's needed for this rule here:

  • Use the same Rules Event, i.e. "Drupal is initializing" (you want to catch this edit event via Rules BEFORE the edit session actually allowed to be started!).

  • Slightly adapt the regular expression, by adding /edit to it.

  • Add an extra condition to verify if the EIP-flag for this node is NOT turned on (which indicates no other edit session for this node exists).

  • Adapt the Rules Action to SET the EIP flag.

Step 4: Create a rule to UNSET the EIP flag when an edit ends

Create a rule to UNSET the EIP flag for a node whenever an authorized user requests to end an edit session for a node.

Here is a summary of this rule:

  • Use Rules Event "after saving content".
  • Use Rules Action to UNSET the EIP flag.

Step 5: Merge Step 2 and Step 3 (optional)

Should you want to do/consider so, you should be able to merge the 2 Rules from Step 2 and Step 3 in a single Rule, using the Conditional Rules module. Refer to my answer to the question How to prevent a node being saved when using the Rules module? for a sample of how to use this module (for which not a lot of documentation seems to exist).

0

When two people edit the same page and one submits changes there is a hight risk that at the same time the second person has made some changes to the same page that will be lost. There, I find, exists the great use of this module.

0

To "unblock" the node for editing it you can clear cache from within the admin page UI. In Drupal 7 it is in main menu, first icon (Home) -> Flush all caches.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.