diff options
author | Satoshi Sahara <sahara.satoshi@gmail.com> | 2022-01-23 13:44:10 +0900 |
---|---|---|
committer | Satoshi Sahara <sahara.satoshi@gmail.com> | 2022-01-23 13:44:10 +0900 |
commit | a644ba8e2f2624166abf43945a2ff57f9af7edf0 (patch) | |
tree | c368dd42008c94cfbeeffed2649a87636ff1dfb6 /inc/Ui | |
parent | 312e70954b2d03b55670ce8dc5afccba9269f4d2 (diff) | |
download | dokuwiki-a644ba8e2f2624166abf43945a2ff57f9af7edf0.tar.gz dokuwiki-a644ba8e2f2624166abf43945a2ff57f9af7edf0.zip |
strict check to find prev and next revision
array_search may return false and treated as 0 when a rev not found revs.
Diffstat (limited to 'inc/Ui')
-rw-r--r-- | inc/Ui/PageDiff.php | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/inc/Ui/PageDiff.php b/inc/Ui/PageDiff.php index 08b830e4b..3830afe12 100644 --- a/inc/Ui/PageDiff.php +++ b/inc/Ui/PageDiff.php @@ -388,12 +388,16 @@ class PageDiff extends Diff $newerRevisions = $this->buildRevisionOptions('newer', $newRevs); // determine previous/next revisions - $index = array_search($oldRev, $oldRevs); - $oldPrevRev = ($index +1 < count($oldRevs)) ? $oldRevs[$index +1] : false; - $oldNextRev = ($index > 0) ? $oldRevs[$index -1] : false; - $index = array_search($newRev, $newRevs); - $newPrevRev = ($index +1 < count($newRevs)) ? $newRevs[$index +1] : false; - $newNextRev = ($index > 0) ? $newRevs[$index -1] : false; + $oldPrevRev = $oldNextRev = false; + if (($index = array_search($oldRev, $oldRevs)) !== false) { + $oldPrevRev = ($index +1 < count($oldRevs)) ? $oldRevs[$index +1] : false; + $oldNextRev = ($index > 0) ? $oldRevs[$index -1] : false; + } + $newPrevRev = $newNextRev = false; + if (($index = array_search($newRev, $newRevs)) !== false) { + $newPrevRev = ($index +1 < count($newRevs)) ? $newRevs[$index +1] : false; + $newNextRev = ($index > 0) ? $newRevs[$index -1] : false; + } /* * navigation UI for older revisions / Left side: |