Avoid overwriting one's content modifications

Discussions and requests related to new CMSimple features, plugins, templates etc. and how to develop.
Please don't ask for support at this forums!
Post Reply
cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Avoid overwriting one's content modifications

Post by cmb » Thu Feb 28, 2013 10:41 pm

Hello Community,

a while ago I was working on two different pages of my CMSimple site in two different tabs to be able to better match them. After having saved the second, the changes in the first were lost. :( This could be improved by storing the mtime of content.htm in a hidden field in the edit form, and comparing that with the current mtime when submitting the form, rejecting to save the modifications, if the stored mtime is less than the current one (i.e. the file was altered in the meantime). OTOH I'm not sure, if that's necessary (perhaps nobody else is working on more than one page in parallel), and if the resulting error message might not irritate the user, or at least won't help him, as he may not know how to solve the problem (copying the modified page contents to the clipboard, reload the page [not F5, but enter in the address line] and replacing the page content with the clipboard).

What do you think?

Christoph

PS: Just noticed, that special care would have to be taken to cater for any modifications of the content, that would be done through AJAX requests (such as the quick saving of a page data tab).
Last edited by cmb on Thu Feb 28, 2013 10:46 pm, edited 1 time in total.
Reason: added PS
Christoph M. Becker – Plugins for CMSimple_XH

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: Avoid overwriting one's content modifications

Post by cmb » Sat Mar 22, 2014 1:55 pm

It's a long time since I opened this topic, so I want to bump it, because IMO it is rather important. Just to make the issue more clear, consider the following scenario:

An admin creates a new page and is going to edit it. After some editing he notices that some parts of this new page are already on another page (at least similar contents/markup), so he opens the other page in a new browser tab to be able to copy the relevant parts to the new page. Then he notices that there's a typo in the old page, quickly fixes it and saves this page. He continues to edit the new page, and after finishing this work he saves it. (Much) later he notices by change that the typo on the "old" page still exists: WTF!?

Telling users to never work in admin mode in more than one browser tab, because CMSimple_XH can't handle that, is IMO embarrassing, so I strongly suggest to fix this issue rather soon.

Solving it for the core with optimistic locking (filemtime() might not be the best choice; sha1_file() would be an alternative) shouldn't be too hard, even regarding the page data tabs. However, plugins that modify core files (such as content.htm) would have to cater for this issue themselves, what obviously requires some kind of API on which the plugins can rely.

Of course, there are similar issues with regard to plugins, so plugin authors should cater for them. For some plugins, namely those that allow editing (parts of) their data in the front-end, the issues are even worse, because changes made by a user might be overwritten by another one. The extreme are plugins such as Register_XH, where any new registrations made while the admin is editing the user list in the back-end will be silently discarded (except for the email notification, which might be rather confusing: "why did I get this email--there's no such user!"). Basically the same can happen with other plugins, for instance, Comments and probably Memberpages_XH.
Christoph M. Becker – Plugins for CMSimple_XH

svasti
Posts: 1651
Joined: Wed Dec 17, 2008 5:08 pm

Re: Avoid overwriting one's content modifications

Post by svasti » Sat Mar 22, 2014 5:20 pm

If you solve this, what about [limited] multiuser support?

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: Avoid overwriting one's content modifications

Post by cmb » Sat Mar 22, 2014 5:44 pm

svasti wrote:If you solve this, what about [limited] multiuser support?
Solving these issues for the core and (most) plugins is a precondition for multiuser support, what does not necessarily mean that multiuser support has to follow. Anyway, first things first.
Christoph M. Becker – Plugins for CMSimple_XH

Post Reply