Skip to content

Commit

Permalink
Merge pull request #870 from Nosto/fix/php-handle-errors
Browse files Browse the repository at this point in the history
Handle json_decode error, when value in null
  • Loading branch information
supercid authored Feb 7, 2025
2 parents b7a621c + 4bbaa88 commit bb9e0b0
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions Helper/Account.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,20 @@ public function findAccount(Store $store)
} catch (NostoException $e) {
throw new RuntimeException($e->getMessage());
}
$tokens = json_decode(
$store->getConfig(self::XML_PATH_TOKENS),
true
);

$tokens = [];
$tokensJson = $store->getConfig(self::XML_PATH_TOKENS);
if (!empty($tokensJson)) {
try {
$tokens = json_decode(
$tokensJson,
true
);
} catch (Exception $e) {
$this->logger->error($e->__toString());
}
}

if (is_array($tokens) && !empty($tokens)) {
foreach ($tokens as $name => $value) {
try {
Expand Down

0 comments on commit bb9e0b0

Please sign in to comment.