From 91aadad8016e1d142f440eb58db68d7b445da1f0 Mon Sep 17 00:00:00 2001 From: Ugljesa Zivaljevic Date: Thu, 19 Dec 2024 15:08:45 +0100 Subject: [PATCH] Handle json_decode error, when value in null --- Helper/Account.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/Helper/Account.php b/Helper/Account.php index dc8c13677..820346881 100644 --- a/Helper/Account.php +++ b/Helper/Account.php @@ -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 {