@@ -542,7 +542,8 @@ public function query($condition = null, $sort = null, $offset = -1, $range = -1
542542 property_exists ($ result ->response , 'data ' ) &&
543543 property_exists ($ result , 'messages ' )
544544 ) {
545- $ fmrel = new FileMakerRelation ($ result ->response ->data , $ result ->response ->dataInfo ,
545+ $ fmrel = new FileMakerRelation ($ result ->response ->data ,
546+ property_exists ($ result ->response , 'dataInfo ' ) ? $ result ->response ->dataInfo : null ,
546547 "OK " , $ result ->messages [0 ]->code , null , $ this ->restAPI );
547548 }
548549 $ this ->restAPI ->logout ();
@@ -581,8 +582,11 @@ public function getRecord($recordId, $portal = null, $script = null)
581582 $ result = $ this ->restAPI ->responseBody ;
582583 $ fmrel = null ;
583584 if ($ result ) {
584- $ dataInfo = clone $ result ->response ->dataInfo ;
585- $ dataInfo ->returnedCount = 1 ;
585+ $ dataInfo = null ;
586+ if (property_exists ($ result ->response , 'dataInfo ' ) && is_object ($ result ->response ->dataInfo )) {
587+ $ dataInfo = clone $ result ->response ->dataInfo ;
588+ $ dataInfo ->returnedCount = 1 ;
589+ }
586590 $ fmrel = new FileMakerRelation ($ result ->response ->data , $ dataInfo ,
587591 "OK " , $ result ->messages [0 ]->code , null , $ this ->restAPI );
588592 }
@@ -1177,11 +1181,13 @@ public function toArray()
11771181 public function getPortalNames ()
11781182 {
11791183 $ list = [];
1180- if (isset ($ this ->data )
1181- && isset ($ this ->data ->portalData )
1182- ) {
1183- foreach ($ this ->data ->portalData as $ key => $ val ) {
1184- array_push ($ list , $ key );
1184+ if (isset ($ this ->data )) {
1185+ foreach ($ this ->data as $ key ) {
1186+ if (property_exists ($ key , 'portalData ' )) {
1187+ foreach ($ key ->portalData as $ name => $ val ) {
1188+ array_push ($ list , $ name );
1189+ }
1190+ }
11851191 }
11861192 }
11871193 return $ list ;
@@ -1212,7 +1218,8 @@ public function field($name, $toName = null)
12121218 isset ($ this ->data [$ this ->pointer ]->portalData ->$ name )
12131219 ) {
12141220 $ value = new FileMakerRelation (
1215- $ this ->data [$ this ->pointer ]->portalData ->$ name , $ this ->data ->portalDataInfo ,
1221+ $ this ->data [$ this ->pointer ]->portalData ->$ name ,
1222+ property_exists ($ this ->data [$ this ->pointer ], 'portalDataInfo ' ) ? $ this ->data [$ this ->pointer ]->portalDataInfo : null ,
12161223 "PORTAL " , 0 , null , $ this ->restAPI );
12171224 }
12181225 }
@@ -1229,7 +1236,8 @@ public function field($name, $toName = null)
12291236 $ value = $ this ->data ->fieldData ->$ name ;
12301237 } else if (isset ($ this ->data ->portalData ) && isset ($ this ->data ->portalData ->$ name )) {
12311238 $ value = new FileMakerRelation (
1232- $ this ->data ->portalData ->$ name , $ this ->data ->portalDataInfo ,
1239+ $ this ->data ->portalData ->$ name ,
1240+ property_exists ($ this ->data , 'portalDataInfo ' ) ? $ this ->data ->portalDataInfo : null ,
12331241 "PORTAL " , 0 , $ name , $ this ->restAPI );
12341242 }
12351243 break ;
@@ -1349,8 +1357,12 @@ public function current()
13491357 if (isset ($ this ->data ) &&
13501358 isset ($ this ->data [$ this ->pointer ])
13511359 ) {
1352- $ dataInfo = clone $ this ->getDataInfo ();
1353- $ dataInfo ->returnedCount = 1 ;
1360+ $ tmpInfo = $ this ->getDataInfo ();
1361+ $ dataInfo = null ;
1362+ if ($ tmpInfo !== null && is_object ($ tmpInfo )) {
1363+ $ dataInfo = clone $ tmpInfo ;
1364+ $ dataInfo ->returnedCount = 1 ;
1365+ }
13541366 $ value = new FileMakerRelation (
13551367 $ this ->data [$ this ->pointer ], $ dataInfo ,
13561368 ($ this ->result == "PORTAL " ) ? "PORTALRECORD " : "RECORD " ,
@@ -1751,7 +1763,11 @@ public function getProductInfo()
17511763 $ returnValue = $ this ->responseBody ->response ->productInfo ;
17521764 }
17531765 } catch (\Exception $ e ) {
1754- throw $ e ;
1766+ if ($ this ->httpStatus == 200 && $ this ->errorCode == 0 ) {
1767+ $ returnValue = array ("version " => 17 );
1768+ } else {
1769+ throw $ e ;
1770+ }
17551771 }
17561772 return $ returnValue ;
17571773 }
0 commit comments