diff --git a/inc/changelog.php b/inc/changelog.php index 570c48740d20a5ec9362e570cb7f8dd2b4a604a2..85de8e2aa655f2aa9fac8b33a9a89e5aa3346f7f 100644 --- a/inc/changelog.php +++ b/inc/changelog.php @@ -271,11 +271,7 @@ function getRevisionInfo($id, $rev, $chunk_size=8192) { * backwards in chunks untill the requested number of changelog * lines are recieved. * - * Because there may exist revisions not listed in the changelog - * the found revisions are merged with the ones found in the attic - * * @author Ben Coburn <btcoburn@silicodon.net> - * @see getRevisionsFromAttic() */ function getRevisions($id, $first, $num, $chunk_size=8192) { global $cache_revinfo; @@ -358,37 +354,7 @@ function getRevisions($id, $first, $num, $chunk_size=8192) { } } - // merge with attic file info - $revs = array_merge($revs,getRevisionsFromAttic($id,false)); - $revs = array_unique($revs); - rsort($revs); - return $revs; } -/** - * Return a list of available and existing page revisons from the attic - * - * @author Andreas Gohr <andi@splitbrain.org> - * @see getRevisions() - */ -function getRevisionsFromAttic($id,$sorted=true){ - $revd = dirname(wikiFN($id,'foo')); - $revs = array(); - $clid = cleanID($id); - if(strrpos($clid,':')) $clid = substr($clid,strrpos($clid,':')+1); //remove path - $clid = utf8_encodeFN($clid); - - if (is_dir($revd) && $dh = opendir($revd)) { - while (($file = readdir($dh)) !== false) { - if (is_dir($revd.'/'.$file)) continue; - if (preg_match('/^'.$clid.'\.(\d+)\.txt(\.gz)?$/',$file,$match)){ - $revs[]=$match[1]; - } - } - closedir($dh); - } - if($sorted) rsort($revs); - return $revs; -} diff --git a/inc/common.php b/inc/common.php index a477f26a19af222d1929051b40ee4a091e4574e6..5edd417d5369dda4cf1cb57b069bca417838fb4b 100644 --- a/inc/common.php +++ b/inc/common.php @@ -691,15 +691,32 @@ function saveWikiText($id,$text,$summary,$minor=false){ } $file = wikiFN($id); - $old = saveOldRevision($id); + $old = @filemtime($file); $wasRemoved = empty($text); $wasCreated = !@file_exists($file); $wasReverted = ($REV==true); $newRev = false; + if(!@file_exists(wikiFN($id, $old)) && @file_exists($file)) { + // 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) { + addLogEntry($old, $id); + // send notify mails + notify($id,'admin',$oldRev,'',false); + notify($id,'subscribers',$oldRev,'',false); + // remove soon to be stale instructions + $cache = new cache_instructions($id, $file); + $cache->removeCache(); + } + } if ($wasRemoved){ // pre-save deleted revision @touch($file); + clearstatcache(); $newRev = saveOldRevision($id); // remove empty file @unlink($file); @@ -719,7 +736,8 @@ function saveWikiText($id,$text,$summary,$minor=false){ }else{ // save file (namespace dir is created in io_writeWikiPage) io_writeWikiPage($file, $text, $id); - $newRev = @filemtime($file); + // pre-save the revision, to keep the attic in sync + $newRev = saveOldRevision($id); $del = false; }