From 1f871298705b9ce4e7c4d9a088efb97d5ba589de Mon Sep 17 00:00:00 2001 From: Jay Date: Mon, 16 Jan 2017 16:41:54 -0600 Subject: [PATCH 1/2] Don't iterate if object is null - Fixes #766. --- lib/PayPal/Common/PayPalResourceModel.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/PayPal/Common/PayPalResourceModel.php b/lib/PayPal/Common/PayPalResourceModel.php index 927a379..6b40e8f 100644 --- a/lib/PayPal/Common/PayPalResourceModel.php +++ b/lib/PayPal/Common/PayPalResourceModel.php @@ -41,9 +41,11 @@ class PayPalResourceModel extends PayPalModel implements IResource public function getLink($rel) { - foreach ($this->links as $link) { - if ($link->getRel() == $rel) { - return $link->getHref(); + if ($this->links) { + foreach ($this->links as $link) { + if ($link->getRel() == $rel) { + return $link->getHref(); + } } } return null; From fbb764f57c984a834ee04dffb4dff7dfc3f6adb3 Mon Sep 17 00:00:00 2001 From: jaypatel512 and sdcoffey Date: Wed, 18 Jan 2017 13:17:08 -0600 Subject: [PATCH 2/2] Check if links is an array --- lib/PayPal/Common/PayPalResourceModel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/PayPal/Common/PayPalResourceModel.php b/lib/PayPal/Common/PayPalResourceModel.php index 6b40e8f..d1ba0f8 100644 --- a/lib/PayPal/Common/PayPalResourceModel.php +++ b/lib/PayPal/Common/PayPalResourceModel.php @@ -41,7 +41,7 @@ class PayPalResourceModel extends PayPalModel implements IResource public function getLink($rel) { - if ($this->links) { + if (is_array($this->links)) { foreach ($this->links as $link) { if ($link->getRel() == $rel) { return $link->getHref();