From e66768a0588e8ade3f72b76e59ac92ad2c9ac3bd Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 24 Feb 2019 14:00:40 -0500 Subject: [PATCH] Add empty entry author if contact query fails in DFRN - Addresses https://github.com/friendica/friendica/issues/6338#issuecomment-462722599 --- src/Protocol/DFRN.php | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/Protocol/DFRN.php b/src/Protocol/DFRN.php index 544e77fa81..e30f027563 100644 --- a/src/Protocol/DFRN.php +++ b/src/Protocol/DFRN.php @@ -763,31 +763,33 @@ class DFRN */ private static function addEntryAuthor(DOMDocument $doc, $element, $contact_url, $item) { - $contact = Contact::getDetailsByURL($contact_url, $item["uid"]); - $author = $doc->createElement($element); - XML::addElement($doc, $author, "name", $contact["name"]); - XML::addElement($doc, $author, "uri", $contact["url"]); - XML::addElement($doc, $author, "dfrn:handle", $contact["addr"]); - /// @Todo - /// - Check real image type and image size - /// - Check which of these boths elements we should use - $attributes = [ + $contact = Contact::getDetailsByURL($contact_url, $item["uid"]); + if (!empty($contact)) { + XML::addElement($doc, $author, "name", $contact["name"]); + XML::addElement($doc, $author, "uri", $contact["url"]); + XML::addElement($doc, $author, "dfrn:handle", $contact["addr"]); + + /// @Todo + /// - Check real image type and image size + /// - Check which of these boths elements we should use + $attributes = [ "rel" => "photo", "type" => "image/jpeg", "media:width" => 80, "media:height" => 80, "href" => $contact["photo"]]; - XML::addElement($doc, $author, "link", "", $attributes); + XML::addElement($doc, $author, "link", "", $attributes); - $attributes = [ + $attributes = [ "rel" => "avatar", "type" => "image/jpeg", "media:width" => 80, "media:height" => 80, "href" => $contact["photo"]]; - XML::addElement($doc, $author, "link", "", $attributes); + XML::addElement($doc, $author, "link", "", $attributes); + } return $author; }