From eba3e63ed567aeba7cd1547c067681a7000569f8 Mon Sep 17 00:00:00 2001 From: Aleksey Filippov Date: Sat, 28 Feb 2026 00:38:15 +0300 Subject: [PATCH] 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 --- erp24/api1/views/cron/domru-cams.php | 3 +++ 1 file changed, 3 insertions(+) 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"]." " ; -- 2.39.5