From 7441bd90c83ba9822d41ab0972c5530d22195557 Mon Sep 17 00:00:00 2001
From: Michael <heluecht@pirati.ca>
Date: Wed, 29 Jul 2020 19:48:26 +0000
Subject: [PATCH] Possibly fix a fatal error

---
 src/Model/Contact.php | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/Model/Contact.php b/src/Model/Contact.php
index 6dbba6ed4..855f90431 100644
--- a/src/Model/Contact.php
+++ b/src/Model/Contact.php
@@ -207,7 +207,12 @@ class Contact
 			if (empty($cid)) {
 				return [];
 			}
-			return self::getById($cid, $fields);
+
+			$contact = self::getById($cid, $fields);
+			if (empty($contact)) {
+				return [];
+			}
+			return $contact;
 		}
 
 		// Add internal fields
@@ -238,6 +243,10 @@ class Contact
 			$contact = DBA::selectFirst('contact', $fields, $condition, $options);
 		}
 		
+		if (!DBA::isResult($contact)) {
+			return [];
+		}
+
 		// Update the contact in the background if needed
 		if ((($contact['updated'] < DateTimeFormat::utc('now -7 days')) || empty($contact['avatar'])) &&
 			in_array($contact['network'], Protocol::FEDERATED)) {