Skip to content

Commit

Permalink
Merge pull request #85 from creative-commoners/pulls/2.4/null-state
Browse files Browse the repository at this point in the history
FIX Handle invalid json data
  • Loading branch information
maxime-rainville authored Jan 26, 2023
2 parents ffe1bc8 + fe5e875 commit 8e3f71a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/TestSessionEnvironment.php
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,10 @@ public function resetDatabaseName()
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;
}

/**
Expand Down

0 comments on commit 8e3f71a

Please sign in to comment.