1

I'm looking in to writing a new PHP based CMS which handles concurrent edits optimistically like source version control rather than pessimistic locking like Wordpress. I want to be able to write some general PHP pages to handle any conflict in a user friendly way so that conflict solving is simple, history is kept and reverting is easy.

I want to use a database and need to design it first. My ideas so far:

  • Have a history table storing all updates like in Wordpress with a version number.

  • When a user saves a record, it will check whether there have been other updates since. This is quite easy to do if you save a checkout version id in the session when the user starts to edit and you can end up with the 3 ids for the saves you want to merge.

How do I display this to the user in a friendly way? I cannot find any information about PHP interfaces for merging things like this. I know there are whole apps like kmerge doing this for just plain text files and I want to know how to do it at a database record level.

Is my design so far solid? What else do I need?

  • Welcome to Programmers! Recommended reading: Where to start? – user22815 May 13 '15 at 22:40
  • Yes, I am looking for a general solution but I disagree that makes my question broad. If you want me to explain something, feel free to ask. – Phil_1984_ May 14 '15 at 10:19
2

Have a history table storing all updates like in Wordpress with a version number.

Yes, but store not updates, but complete revisions (contents of each edit). If you need to save space, compress it. But don't care too much about the size. Humans are rarely capable of producing large volumes of data by themselves. There are many libraries, that can compute diffs between two versions and you can display them to user in a very friendly way.

When a user saves a record, it will check whether there have been other updates since. This is quite easy to do if you save a checkout version id in the session when the user starts to edit and you can end up with the 3 ids for the saves you want to merge.

You just need to differentiate content revisions and content drafts. When user edits some text, the only thing that gets saved should be a draft of his work. No need to store revisions of drafts. Only when user confirms to propagate his changes as final ones, a revision is created.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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