]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
fix(ERP-245): prevent TypeError when Domru XML has single count element
authorAleksey Filippov <Aleksey.Filippov@erp-flowers.ru>
Fri, 27 Feb 2026 21:38:15 +0000 (00:38 +0300)
committerAleksey Filippov <Aleksey.Filippov@erp-flowers.ru>
Fri, 27 Feb 2026 21:38:15 +0000 (00:38 +0300)
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 <noreply@anthropic.com>
erp24/api1/views/cron/domru-cams.php

index 7341d122b3dabb493d8111144cc1ccda50de06e9..6c0c6d70153666bae8397f32edfac1cf78e20ed7 100644 (file)
@@ -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"<br>DateTime=".$arr["DateTime"]." $id =>".$arr["CameraName"]."  CameraID=".$arr["CameraID"]."    value=".$arr["Value"]." " ;