Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dokuwiki
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
BRIC
dokuwiki
Commits
0f13c836
Commit
0f13c836
authored
11 years ago
by
Gerrit Uitslag
Browse files
Options
Downloads
Patches
Plain Diff
Improved isCurrentRevision(), tests included
parent
ee33e0c5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
_test/tests/inc/changelog_getrelativerevision.test.php
+35
-0
35 additions, 0 deletions
_test/tests/inc/changelog_getrelativerevision.test.php
inc/changelog.php
+4
-3
4 additions, 3 deletions
inc/changelog.php
with
39 additions
and
3 deletions
_test/tests/inc/changelog_getrelativerevision.test.php
+
35
−
0
View file @
0f13c836
...
...
@@ -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
This diff is collapsed.
Click to expand it.
inc/changelog.php
+
4
−
3
View file @
0f13c836
...
...
@@ -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
))
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment