Skip to content

Commit 26bc8b8

Browse files
authored
Merge pull request #27 from rbnmulder/master
Check if data from API is truly in array format
2 parents fddabc2 + 36a8fdf commit 26bc8b8

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/Resources/Product.php

+7-3
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,19 @@ public function getList($query = [])
2929
try {
3030
$products = $this->resourceClient->getResources($query);
3131

32-
$this->cacheWrapper->storeCachedList($products, $query);
33-
return $products;
32+
if (is_array($products)) {
33+
$this->cacheWrapper->storeCachedList($products, $query);
34+
return $products;
35+
} else {
36+
return [];
37+
}
3438
} catch (DpdException $e) {
3539
$result = $this->cacheWrapper->getCachedList($query, true); //a year
3640

3741
// So we had a failure save cache now for an hour
3842
$this->cacheWrapper->storeCachedList($result, $query);
3943

40-
if ($result) {
44+
if ($result && is_array($result)) {
4145
return $result;
4246
}
4347
return [];

0 commit comments

Comments
 (0)