Mailing List Archive

FileReplacement implementation strategy
Here's how I think the FileReplacement proposal

http://www.wikipedia.org/pipermail/wikipedia-l/2003-January/008537.html
http://www.usemod.com/cgi-bin/mb.pl?FileReplacement

should be implemented (Jimbo and Brion agreed that it would be a good
idea):

1) Add a copy_of int(8) column to the CUR table. If blank or 0, the
article is not a copy. This saves us the trouble of creating a dozen
Copy/Copy talk namespaces.

2) Change the "Protect this page" link to a more general "Protection
settings" special page, looking roughly like this:

Protection settings
-------------------
[*] Page is not protected

[ ] Only copy is editable. Page is replaced with copy

[*] [ ] minutes after the last edit
[ ] manually

[Save]

(The timed auto-replacement might cause problems especially for less
active wikis. How we set the policy is a matter for wikipedia-l.)

The time (null or 0 for unprotected, -1 for manual replacement,
otherwise number of minutes after which article is replaced) could be
stored in the cur_restrictions field of the cur table.

2) Once the page is protected this way, copy page contents to a separate
page with the title appended by "(COPY)" and is_copy set to the
referenced article ID. If there is already a COPY, copy it to the OLD
table first.

3) Now we need a way to automatically do the following:
1) start OR reset a timer when someone edits the page
2) replace the article with the COPY once the timer has elapsed.

I'm a bit clueless as to whether there is a good Apache/PHP-based
solution for such a persistent timer, cron seems like a bad choice
(makes the whole thing harder to maintain). The way I would do it is as
follows:

Create a new action table:

action_type page_id action_time

When someone edits a COPY and the protection is not set to manual, set
action_type=1 (copy) and action_time=<current server time> + <copy time
period>.

In wiki.phtml, we have two lines

#
$wgOut->output();
foreach ( $wgDeferredUpdateList as $up ) { $up->doUpdate(); }
#

Between these lines we could insert a function call that checks if there
is anything in the ACTION table and if so, picks a random row (or all
rows, not sure about the load this would cause), creates a new Update
object for that row and adds it to the deferred update list. That way we
would regularly replace the original pages with their copies. Once the
page has been copied, the row is removed from the ACTION table.

User interface
--------------
From an UI perspective, we would add an "Edit copy" link under the
"Protected page" text. There should also be some dynamically generated
explanatory text on the COPY page:

"This is a copy of $1."

+

"This copy is different from the current revision of [[$2]]. It will
automatically replace it at $3 unless someone else edits it, in which
case the timer is reset to $4 minutes."

OR

"This copy is identical to the current revision of [[$2]]. If it is
edited, it will automatically replace it $4 hours later."

Sysops should also be shown a "Use this revision" link to execute the
copy action immediately.

Discussion
----------
I would be especially interested in feedback on
- "Copy:/Copy talk:/User copy:/User copy talk:..." namespaces vs.
copy_of column vs. ???
- Timed action execution: other strategies; always check all rows of the
table?

As always, I am happy if someone else adds this to their todo list,
otherwise I'll add it to mine.

Regards,

Erik
--
FOKUS - Fraunhofer Insitute for Open Communication Systems
Project BerliOS - http://www.berlios.de