Terence wrote:
Murray @ PlanetThoughtful wrote:
Hi All,
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?
We use a combination of locking the record using a simple boolean
column together with the user id who has locked the item and the
timestamp.
The locking prevents another user from opening the form and happily
editing away without realising his changes will be lost when he
presses submit. The user id is to inform the second user who has
opened the document, and the timestemp is so that the first guy doesnt
open the document and go out for lunch leaving it locked. We default
it to 5 minutes after which someone else can open the document and
edit it.
I think I'm going to go with Jasper's suggestion, re: simply
timestamping the current edit from the preceding version and testing
that timestamp against the existence of more recent edits and throwing
back to the user a request to resolve their changes against the now
'current' version.
I had been thinking about a timed locking strategy (5 minutes seems
short, though, for content creation, and what do you currently do when
person A comes back from lunch, person B has made an edit in the same
entry after person A's lock timed out, and person A commits their now
aged edit? Do you basically throw an error anyway, and ask person A to
resolve?), and perhaps implementing a simple javascript countdown on the
page to alert the person editing the page when time for their edit is
running out, but in all honesty I think throwing back the error, and
perhaps presenting a diff of the newer version of the entry, and the
version the user has edited, might be the way to go.
Either way, gives me plenty to think about.
Out of curiosity, does anyone know if it's possible to tell whether an
individual session is still alive from PHP? I don't mean from within
code being run for a particular user, but in code that, for example,
might be executed by a cron job, which would examine a table in which
session ids have been recorded automatically for each visitor, and
determining which of those sessions are still theoretically alive? I
suspect this isn't possible, but I've also learned to never
underestimate the ingenuity of those faced with things that aren't possible.
Much warmth,
Murrray @ PlanetThoughftul
---
"A man, a canoe, and a dream to climb Mt Everest..."
http://www.planetthoughtful.org
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php