throw meaningful exception if non-array record is detected
authorPhilipp Schüle <p.schuele@metaways.de>
Sat, 8 Mar 2014 09:31:43 +0000 (10:31 +0100)
committerPhilipp Schüle <p.schuele@metaways.de>
Wed, 10 Sep 2014 11:06:24 +0000 (13:06 +0200)
Change-Id: Ic68031a5abf9333b8f2c2b20a9ea31b19e7ce6a9
Reviewed-on: http://gerrit.tine20.com/customers/422
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tine20/Tinebase/Frontend/Json/Abstract.php

index 0a8ac13..6284c37 100644 (file)
@@ -325,9 +325,15 @@ abstract class Tinebase_Frontend_Json_Abstract extends Tinebase_Frontend_Abstrac
                     if ($record->has($property) && $record->{$property}) {
                         $recordSet = new Tinebase_Record_RecordSet($rcn);
                         foreach ($record->{$property} as $recordArray) {
-                            $srecord = new $rcn(array(), true);
-                            $srecord->setFromJsonInUsersTimezone($recordArray);
-                            $recordSet->addRecord($srecord);
+                            if (is_array($recordArray)) {
+                                $srecord = new $rcn(array(), true);
+                                $srecord->setFromJsonInUsersTimezone($recordArray);
+                                $recordSet->addRecord($srecord);
+                            } else {
+                                if (Tinebase_Core::isLogLevel(Zend_Log::ERR)) Tinebase_Core::getLogger()->err(__METHOD__ . '::' . __LINE__
+                                    . ' Record array expected, got: ' . $recordArray);
+                                throw new Tinebase_Exception_InvalidArgument('Record array expected');
+                            }
                         }
                         $record->{$property} = $recordSet;
                     }