Skip to content
Snippets Groups Projects
Commit 626261db authored by Andreas Gohr's avatar Andreas Gohr Committed by GitHub
Browse files

Merge pull request #1675 from lisps/patch-2

fix calculation of LastRevisionAt
parents 611545d9 cad89f56
No related branches found
No related tags found
No related merge requests found
......@@ -124,4 +124,41 @@ class changelog_getlastrevisionat_test extends DokuWikiTest {
$current = $pagelog->getLastRevisionAt($rev);
$this->assertEquals($currentexpected, $current);
}
}
\ No newline at end of file
/**
* test get correct revision on deleted media
*
*/
function test_deletedimage() {
global $conf;
global $AUTH_ACL;
//we need to have a user with AUTH_DELETE rights
//save settings
$oldSuperUser = $conf['superuser'];
$oldUseacl = $conf['useacl'];
$oldRemoteUser = $_SERVER['REMOTE_USER'];
$conf['superuser'] = 'admin';
$conf['useacl'] = 1;
$_SERVER['REMOTE_USER'] = 'admin';
$image = 'wiki:imageat.png';
$ret = copy(mediaFn('wiki:kind_zu_katze.png'),mediaFn($image));
$revexpected = @filemtime(mediaFn($image));
$rev = $revexpected + 10;
$ret = media_delete($image, 0);
$medialog = new MediaChangelog($image);
$current = $medialog->getLastRevisionAt($rev);
$this->assertEquals($revexpected, $current);
//restore settings
$_SERVER['REMOTE_USER'] = $oldRemoteUser;
$conf['superuser'] = $oldSuperUser;
$conf['useacl'] = $oldUseacl;
}
}
......@@ -881,7 +881,7 @@ abstract class ChangeLog {
*/
function getLastRevisionAt($date_at){
//requested date_at(timestamp) younger or equal then modified_time($this->id) => load current
if($date_at >= @filemtime($this->getFilename())) {
if(file_exists($this->getFilename()) && $date_at >= @filemtime($this->getFilename())) {
return '';
} else if ($rev = $this->getRelativeRevision($date_at+1, -1)) { //+1 to get also the requested date revision
return $rev;
......
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