From e6bcd3e44c14785a14ee1321c95d4644227f1565 Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Thu, 27 Sep 2018 07:39:53 -0400 Subject: [PATCH] Fix issue processwire/processwire-issues#712 to correct issue with $config->sessionHistory=1; setting not working correctly --- wire/core/Session.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/wire/core/Session.php b/wire/core/Session.php index 17eede32..4fe27fb1 100644 --- a/wire/core/Session.php +++ b/wire/core/Session.php @@ -1199,7 +1199,13 @@ class Session extends Wire implements \IteratorAggregate { end($history); $lastKey = key($history); $nextKey = $lastKey+1; - if($cnt >= $historyCnt) $history = array_slice($history, -1 * ($historyCnt-1), null, true); + if($cnt >= $historyCnt) { + if($historyCnt > 1) { + $history = array_slice($history, -1 * ($historyCnt - 1), null, true); + } else { + $history = array(); + } + } } else { $nextKey = 0; }