Skip to content

Commit

Permalink
Handle json_decode error, when value in null
Browse files Browse the repository at this point in the history
  • Loading branch information
ugljesaspx committed Dec 19, 2024
1 parent 1bc18ec commit 91aadad
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 91aadad

Please sign in to comment.