From: Aleksey Filippov Date: Fri, 27 Feb 2026 21:38:15 +0000 (+0300) Subject: fix(ERP-245): prevent TypeError when Domru XML has single count element X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=eba3e63ed567aeba7cd1547c067681a7000569f8;p=erp24_rep%2Fyii-erp24%2F.git fix(ERP-245): prevent TypeError when Domru XML has single count element When XML response contains only one count element, json_decode(json_encode($xml)) produces a flat array instead of nested, causing $arr to be a string. Skip non-array entries to avoid "Cannot access offset of type string on string". Co-Authored-By: Claude Opus 4.6 --- diff --git a/erp24/api1/views/cron/domru-cams.php b/erp24/api1/views/cron/domru-cams.php index 7341d122..6c0c6d70 100644 --- a/erp24/api1/views/cron/domru-cams.php +++ b/erp24/api1/views/cron/domru-cams.php @@ -153,6 +153,9 @@ if ($sid == null) { $maas = json_decode(json_encode($xml), true); asort($maas); foreach ($maas["count"] ?? [] as $id => $arr) { + if (!is_array($arr)) { + continue; + } //echo"
DateTime=".$arr["DateTime"]." $id =>".$arr["CameraName"]." CameraID=".$arr["CameraID"]." value=".$arr["Value"]." " ;