From bf6a765beb99a692bbdce96816b4a6405966bdd7 Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Sun, 24 Feb 2019 16:30:09 +0100 Subject: [PATCH 1/2] Fixing appending child at DFRN without a parent id. --- src/Protocol/DFRN.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Protocol/DFRN.php b/src/Protocol/DFRN.php index e6524de965..cf8f18866e 100644 --- a/src/Protocol/DFRN.php +++ b/src/Protocol/DFRN.php @@ -119,7 +119,9 @@ class DFRN $item["entry:cid"] = defaults($item, "entry:cid", 0); $entry = self::entry($doc, "text", $item, $owner, $item["entry:comment-allow"], $item["entry:cid"]); - $root->appendChild($entry); + if (isset($entry)) { + $root->appendChild($entry); + } } return trim($doc->saveXML()); @@ -323,7 +325,9 @@ class DFRN } $entry = self::entry($doc, $type, $item, $owner, true); - $root->appendChild($entry); + if (isset($entry)) { + $root->appendChild($entry); + } } $atom = trim($doc->saveXML()); @@ -390,7 +394,9 @@ class DFRN foreach ($items as $item) { $entry = self::entry($doc, $type, $item, $owner, true, 0); - $root->appendChild($entry); + if (isset($entry)) { + $root->appendChild($entry); + } } } else { $root = self::entry($doc, $type, $item, $owner, true, 0, true); @@ -916,7 +922,8 @@ class DFRN $mentioned = []; if (!$item['parent']) { - return; + Logger::notice('Item without parent found.', ['type' => $type, 'item' => $item]); + return null; } if ($item['deleted']) { From 5d13b94761588c6ebca4aab2abcd03a22e00fcd8 Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Sun, 24 Feb 2019 16:31:16 +0100 Subject: [PATCH 2/2] update phpdoc --- src/Protocol/DFRN.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Protocol/DFRN.php b/src/Protocol/DFRN.php index cf8f18866e..98f42b9a9e 100644 --- a/src/Protocol/DFRN.php +++ b/src/Protocol/DFRN.php @@ -912,7 +912,7 @@ class DFRN * @param int $cid Contact ID of the recipient * @param bool $single If set, the entry is created as an XML document with a single "entry" element * - * @return \DOMElement XML entry object + * @return null|\DOMElement XML entry object * @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \ImagickException * @todo Find proper type-hints