Skip to content

Commit defe4f5

Browse files
committed
Fix getPortalNames()
1 parent 9d94170 commit defe4f5

1 file changed

Lines changed: 17 additions & 10 deletions

File tree

FMDataAPI.php

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -582,8 +582,11 @@ public function getRecord($recordId, $portal = null, $script = null)
582582
$result = $this->restAPI->responseBody;
583583
$fmrel = null;
584584
if ($result) {
585-
$dataInfo = clone $result->response->dataInfo;
586-
$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+
}
587590
$fmrel = new FileMakerRelation($result->response->data, $dataInfo,
588591
"OK", $result->messages[0]->code, null, $this->restAPI);
589592
}
@@ -1178,11 +1181,13 @@ public function toArray()
11781181
public function getPortalNames()
11791182
{
11801183
$list = [];
1181-
if (isset($this->data)
1182-
&& isset($this->data->portalData)
1183-
) {
1184-
foreach ($this->data->portalData as $key => $val) {
1185-
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+
}
11861191
}
11871192
}
11881193
return $list;
@@ -1213,7 +1218,8 @@ public function field($name, $toName = null)
12131218
isset($this->data[$this->pointer]->portalData->$name)
12141219
) {
12151220
$value = new FileMakerRelation(
1216-
$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,
12171223
"PORTAL", 0, null, $this->restAPI);
12181224
}
12191225
}
@@ -1230,7 +1236,8 @@ public function field($name, $toName = null)
12301236
$value = $this->data->fieldData->$name;
12311237
} else if (isset($this->data->portalData) && isset($this->data->portalData->$name)) {
12321238
$value = new FileMakerRelation(
1233-
$this->data->portalData->$name, $this->data->portalDataInfo,
1239+
$this->data->portalData->$name,
1240+
property_exists($this->data, 'portalDataInfo') ? $this->data->portalDataInfo : null,
12341241
"PORTAL", 0, $name, $this->restAPI);
12351242
}
12361243
break;
@@ -1352,7 +1359,7 @@ public function current()
13521359
) {
13531360
$tmpInfo = $this->getDataInfo();
13541361
$dataInfo = null;
1355-
if ($tmpInfo !== null) {
1362+
if ($tmpInfo !== null && is_object($tmpInfo)) {
13561363
$dataInfo = clone $tmpInfo;
13571364
$dataInfo->returnedCount = 1;
13581365
}

0 commit comments

Comments
 (0)