Multi-user editing alert
Has this ever happened to you? You are merrily editing your SilverStripe website, working on a large update to one of your pages. You finish your update, hit “save & publish” and walk away, thinking you did a great job. Then your boss phones and asks why the update isn’t live yet. At this point you are confused, thinking: “I could have sworn I hit that ‘save & publish’ button.” You log in to the CMS and your update is gone!
After much investigating, it turns out your co-worker Edith Concurrent was editing pages at the same time that you were, and she corrected a minor typo on the same page that you were working on, overwriting your changes.
How do you prevent that kind of thing happening? Well, now there is a solution. I've created a new SilverStripe module: Install the Multi-User Editing Alert module!
Once installed, you will see blue dots in the page tree showing you who is editing at the same time that you are. If you see a red dot that is a conflict where multiple people are on the same page. It’s up to you to use your favourite communication tool to talk to your colleague and discuss who should be editing and saving changes.
As simple as that.
The module works by pinging the server every few seconds with the page that you are currently editing. It also downloads the location of every other content editor in the same API call. To prevent the ping taxing server resources, I’ve made it run in under 150ms. Indeed, most of that time is SilverStripe overhead, the code itself runs in just 12ms.
How does it work so quickly, you ask? It doesn’t use a database—that’s how. It uses the SS_Cache on the local filesystem, or DynamicDB, if you are running on SilverStripe Platform, to save the current state of all editors.
Note: there are still database queries to verify your logged-in state, so can’t run entirely without accessing the database, unfortunately. Also, running a flush clears all the state, if something were to go horribly wrong with the module.
The view of who is editing where updates dynamically as people move around, so you don’t need to refresh the page to see an updated view. Also, all the parties involved in an editing conflict see the alert, if there is a conflict.
You can control the ping frequency with the SilverStripe config system. So, if you have thousands of people editing your site concurrently, then perhaps increase the length of time between each ping to prevent your server crashing. Also, if you are the only person editing at a given point in time, the default ping frequency goes from 3 seconds to 24 seconds to save some server resources. Though again, you can easily adjust these values to anything you like.
If someone logs out, or their browser crashes, the module removes them from the editing alert after 70 seconds of not hearing from them. Naturally, you can modify this timeout period using the config system.
The multiuser-editing-alert module merely alerts you to other’s presence, it doesn’t lock anyone out of editing. If you want to lock users out from editing concurrently, then you can install the Edit Lock module instead.
Or even install both at the same time, as the two modules play nicely together.