I've recently been working on building my own wiki engine for my blog
site. While the majority of the engine is complete, a remaining concern
I have is how to handle competing edits (ie when two or more people are
editing the same wiki page simultaneously).
I'm wondering if anyone else on the list has given this some thought?
How would / do you handle competing edits to the same entry in a wiki
application?
Just to add a little extra information: all 'edits' are in fact
'inserts'. Entries are stored in a mysql table. The engine simply
displays the most recent record for the entry being viewed. This is, of
course, to allow for retrieval of an historical version of the entry
should one or more entries be vandalized.
Seems like you have a couple of choices.
1 - Lock the page when the first user edits it until they save their
changes. Has the advantage that it's pretty easy code-wise. The
disadvantage being that if that first user leaves, but doesn't save/cancel
his edit, how/when do you decide to release lock? This would be similar
to how Visual Source Safe or RCS does it.
2 - Allow shared edits and programatically merge the changes back into the
master document. This is how CVS does it. So you could do something like
this:
- user A starts editing document.
- user B starts editing document.
- user A saves his changes. this copy is now the most recent as the
system would check to see that no changes were made to the "master copy"
while user A was making changes.
- user B saves his changes. the system would see that the "master copy"
had been updated and would merge the changes into B's copy and save that.
In this last step you could do it a couple of different ways.
When user B saves his changes, the system could create a diff file between
the most recent version of the document and the one that was the basis for
B's changes -- this would be the changes user A made. Then you could
merge those changes into B's document. If there was a conflict (ie. user
A and user B made changes to the same line) user B would have to resolve
the differences. This is exactly how CVS handles it.
Or, you could just create a diff file and make user B manually apply the
patch until he's happy.
If you have access to a unix box take a look at the 'diff' and 'patch'
commands...
good luck!
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php