Skip to content
Snippets Groups Projects
Commit 0f13c836 authored by Gerrit Uitslag's avatar Gerrit Uitslag
Browse files

Improved isCurrentRevision(), tests included

parent ee33e0c5
No related branches found
No related tags found
No related merge requests found
......@@ -270,4 +270,39 @@ class changelog_getrelativerevision_test extends DokuWikiTest {
$revfound = $pagelog->getRelativeRevision($rev, $dir, $media = false);
$this->assertEquals($revexpected, $revfound);
}
function test_iscurrentpagerevision() {
$rev = 1385051947;
$currentexpected = true;
//set a known timestamp
touch(wikiFN($this->pageid), $rev);
$pagelog = new PageRevisionLog($this->pageid, $chunk_size = 8192);
$current = $pagelog->isCurrentRevision($rev, $media = false);
$this->assertEquals($currentexpected, $current);
}
function test_isnotcurrentpagerevision() {
$rev = 1385051947;
$not_current_rev = $rev - 1;
$currentexpected = false;
//set a known timestamp
touch(wikiFN($this->pageid), $rev);
$pagelog = new PageRevisionLog($this->pageid, $chunk_size = 8192);
$current = $pagelog->isCurrentRevision($not_current_rev, $media = false);
$this->assertEquals($currentexpected, $current);
}
function test_notexistingcurrentpage() {
$rev = 1385051947;
$currentexpected = false;
$pagelog = new PageRevisionLog('nonexistingpage', $chunk_size = 8192);
$current = $pagelog->isCurrentRevision($rev, $media = false);
$this->assertEquals($currentexpected, $current);
}
}
\ No newline at end of file
......@@ -760,11 +760,12 @@ class PageRevisionLog {
/**
* Check whether given revision is the current page
*
* @param int $rev timestamp of current page
* @param int $rev timestamp of current page
* @param bool $media look for media?
* @return bool true if $rev is current revision, otherwise false
*/
public function isCurrentRevision($rev){
return isset($INFO['meta']['last_change']) && $rev == $INFO['meta']['last_change']['date'];
public function isCurrentRevision($rev, $media = false) {
return $rev == @filemtime($media ? mediaFN($this->id) : wikiFN($this->id));
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment