From fcfd50a85c54324e4555075624bdd213871310a7 Mon Sep 17 00:00:00 2001 From: Damien Regad Date: Wed, 27 Jan 2021 00:41:45 +0100 Subject: [PATCH] Fix Undefined array keys in Diff.php Occurs when the selected revision is the first or last of the list, for both the left and right revs. --- inc/Ui/Diff.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/inc/Ui/Diff.php b/inc/Ui/Diff.php index 3d159e4c7..513e0667c 100644 --- a/inc/Ui/Diff.php +++ b/inc/Ui/Diff.php @@ -18,7 +18,7 @@ class Diff extends Ui protected $showIntro; protected $difftype; - /** + /** * Diff Ui constructor * * @param string $text when non-empty: compare with this text with most current version @@ -368,12 +368,12 @@ class Diff extends Ui //determine previous/next revisions $l_index = array_search($l_rev, $l_revs); - $l_prev = $l_revs[$l_index + 1]; - $l_next = $l_revs[$l_index - 1]; + $l_prev = $l_index < count($l_revs) - 1 ? $l_revs[$l_index + 1] : null; + $l_next = $l_index > 1 ? $l_revs[$l_index - 1] : null; if ($r_rev) { $r_index = array_search($r_rev, $r_revs); - $r_prev = $r_revs[$r_index + 1]; - $r_next = $r_revs[$r_index - 1]; + $r_prev = $r_index < count($r_revs) - 1 ? $r_revs[$r_index + 1] : null; + $r_next = $r_index > 1 ? $r_revs[$r_index - 1] : null; } else { //removed page if ($l_next) { -- 2.11.4.GIT