From fe5e87598fd8876071c38293b0898aea18e67b2b Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Tue, 24 Jan 2023 14:38:01 +1300 Subject: [PATCH] FIX Handle invalid json data --- src/TestSessionEnvironment.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/TestSessionEnvironment.php b/src/TestSessionEnvironment.php index 0a729e3..1b9fb1f 100644 --- a/src/TestSessionEnvironment.php +++ b/src/TestSessionEnvironment.php @@ -529,7 +529,10 @@ class TestSessionEnvironment public function getState() { $path = Director::getAbsFile($this->getFilePath()); - return (file_exists($path ?? '')) ? json_decode(file_get_contents($path)) : new stdClass; + if (file_exists($path ?? '')) { + return json_decode(file_get_contents($path)) ?: new stdClass; + } + return new stdClass; } /**