mirror of
https://github.com/silverstripe/silverstripe-testsession
synced 2024-10-22 14:06:00 +02:00
Merge pull request #85 from creative-commoners/pulls/2.4/null-state
FIX Handle invalid json data
This commit is contained in:
commit
8e3f71afb7
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user