39

This request comes as an extension of this discussion.

Scenario:

Someone with full editing rights (2k+ rep) edits a post and makes logical common improvements. Concurrently, someone with limited editing rights (< 2k rep) suggests a similar edit but seconds after the other edit was made.

Result:

The suggested edit gets merged with the previous edit, resulting in either an insignificant edit or in worse cases, a rollback of some of the fixes of the previous edit, ultimately getting it rejected.

  1. Best case scenario, the edit appears to be minor spacing changes, probably non-detrimental but ultimately unnecessary as a suggestion (similarily to the linked post).
  2. Worst case scenario, the edit appears to be detrimental to the current quality of the post as it takes away from the most recent edit, and the editor appears to be suggesting harmful edits that worsen the quality of question or answer.

Request:

As the title suggests, warn users suggesting edits when another person edits the question within a certain period of time. I know that there is a card that shows up at the top of the edit UI when a new edit is made while you are editing, but this is known to come to with its own UI limitations, Internet connectivity issues, etc. So the hope is to provide a more stable way of informing editors of possible conflicts to avoid these issues.

2
  • why no websockets? is it too heavy a load on the server?
    – starball
    Apr 5 at 5:50
  • 4
    @user websockets already routinely fail for all sorts of reasons. Maybe the SE network is down for a moment, maybe a router/firewall/something decides to cut their connection. Or even more simply - the user's internet is down for a moment and thus the websocket connection is off. That's literally issues on SE with websockets. But other than that, best practice is always to verify user data on the backend anyway and to never rely on a frontend-only solution that affects user submissions.
    – VLAZ
    Apr 5 at 5:57

2 Answers 2

20

Personal suggestion:

When someone clicks the submit button to suggest an edit, perform an internal check for recent edits (within the last minute perhaps) and warn the editor of potential conflicts if one exists. This will give the editor the chance to review the newly added edit and potentionally overcome the UI limitation.

The added benefit here is that a popup would be significantly more noticible than the current card at the top of the edit page, so it would also help situations where editors might simply not notice that an edit was made even if it showed up for them.

As I am unfamiliar with SO's code, I do not know if this is actually feasable, but the general idea I am going for is a more action triggered server-side check rather than a real-time UI update as intuitively I believe it would result in a more consistent experience.

4
  • 4
    As opposed to checking edit times, I would suggest checking states. User 1 makes a post in state A. User 2 edits the post and is in state B. User 3 is editing state A and when submitting, it alerts user 3 that the post is no longer in state A. I'm sure some people have implemented something like this before. Surely. Apr 4 at 19:19
  • @TimothyJames It's a cool idea, not entirely clear in my head how it would work exactly, but you should elaborate on it and write it as an answer if you want I think, would provide more options for the community to "vote" on if this post gets traction (seems to be doing well) Apr 4 at 19:41
  • I was basically alluding to git/version control. Not much more than that. Other than that, the UI elements to alert the user is the most important part in preventing the issue from cropping up. Apr 4 at 20:06
  • 1
    @TimothyJames: Yes, that could maybe work, with the edit page knowing what revision of the post it was loaded from. Submitting that along with the new contents would let the server compare. And/or perhaps a hash of the contents when the editor opened, in case of edits during the 5-minute grace period after that revision was submitted. Apr 5 at 3:57
-10

It is actually pretty easy to detect edit conflicts. All it requires is an UpdateId field in the file you want to protect. When you retrieve the record to be updated, you include the UpdateID field, on update you increment that field. So now you can hold up the update if the UpdateID field is not what you expected it to be when the edit is submitted. This approach is called Optimistic locking. It is discussed more in depth here: Optimistic vs. Pessimistic Locking

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .