From a701424f8d6706a4fbbd1317907bc0e92b382873 Mon Sep 17 00:00:00 2001 From: Ben Coburn Date: Fri, 27 Oct 2006 02:00:43 +0200 Subject: synchronize changelog, attic, and external edits - update 1 Removed a minor error that could be caused by a page back-dated into the past. Also, added some more code comments. darcs-hash:20061027000043-05dcb-1ccbb4c98b1b7b3358d99d8f097eb168d84259b7.gz --- inc/common.php | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'inc/common.php') diff --git a/inc/common.php b/inc/common.php index 5edd417d5..797ff0525 100644 --- a/inc/common.php +++ b/inc/common.php @@ -676,12 +676,19 @@ function con($pre,$text,$suf,$pretty=false){ } /** - * Saves a wikitext by calling io_writeWikiPage + * Saves a wikitext by calling io_writeWikiPage. + * Also directs changelog and attic updates. * * @author Andreas Gohr * @author Ben Coburn */ function saveWikiText($id,$text,$summary,$minor=false){ + /* Note to developers: + This code is subtle and delicate. Test the behavior of + the attic and changelog with dokuwiki and external edits + after any changes. External edits change the wiki page + directly without using php or dokuwiki. + */ global $conf; global $lang; global $REV; @@ -691,18 +698,18 @@ function saveWikiText($id,$text,$summary,$minor=false){ } $file = wikiFN($id); - $old = @filemtime($file); + $old = @filemtime($file); // from page $wasRemoved = empty($text); $wasCreated = !@file_exists($file); $wasReverted = ($REV==true); $newRev = false; - if(!@file_exists(wikiFN($id, $old)) && @file_exists($file)) { + $oldRev = getRevisions($id, -1, 1, 1024); // from changelog + $oldRev = (int)(empty($oldRev)?0:$oldRev[0]); + if(!@file_exists(wikiFN($id, $old)) && @file_exists($file) && $old>=$oldRev) { // add old revision to the attic if missing saveOldRevision($id); // add a changelog entry if this edit came from outside dokuwiki - $oldRev = getRevisions($id, -1, 1, 1024); - $oldRev = (int)(empty($oldRev)?0:$oldRev[0]); - if ($oldRev!==$old) { + if ($old>$oldRev) { addLogEntry($old, $id); // send notify mails notify($id,'admin',$oldRev,'',false); -- cgit v1.2.3