$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());
}
$entry = self::entry($doc, $type, $item, $owner, true);
- $root->appendChild($entry);
+ if (isset($entry)) {
+ $root->appendChild($entry);
+ }
}
$atom = trim($doc->saveXML());
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);
*/
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;
}
* @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
$mentioned = [];
if (!$item['parent']) {
- return;
+ Logger::notice('Item without parent found.', ['type' => $type, 'item' => $item]);
+ return null;
}
if ($item['deleted']) {
$author["network"] = $contact_old["network"];
} else {
if (!$onlyfetch) {
- Logger::log("Contact ".$author["link"]." wasn't found for user ".$importer["importer_uid"]." XML: ".$xml, Logger::DEBUG);
+ Logger::debug("Contact ".$author["link"]." wasn't found for user ".$importer["importer_uid"]." XML: ".$xml);
}
$author["contact-unknown"] = true;
if (empty($author['avatar'])) {
Logger::log('Empty author: ' . $xml);
+ $author['avatar'] = '';
}
if (DBA::isResult($contact_old) && !$onlyfetch) {
}
$notice_info = $xpath->query("statusnet:notice_info", $entry);
- if ($notice_info && ($notice_info->length > 0) && !empty($notice_info->item)) {
- foreach ($notice_info->item[0]->attributes as $attributes) {
+ if ($notice_info && ($notice_info->length > 0)) {
+ foreach ($notice_info->item(0)->attributes as $attributes) {
if ($attributes->name == "source") {
$item["app"] = strip_tags($attributes->textContent);
}
$item['conversation-uri'] = XML::getFirstNodeValue($xpath, 'ostatus:conversation/text()', $entry);
$conv = $xpath->query('ostatus:conversation', $entry);
- if (!empty($conv->item[0])) {
- foreach ($conv->item[0]->attributes as $attributes) {
+ if (is_object($conv->item(0))) {
+ foreach ($conv->item(0)->attributes as $attributes) {
if ($attributes->name == "ref") {
$item['conversation-uri'] = $attributes->textContent;
}
$item["parent-uri"] = $item["uri"];
$inreplyto = $xpath->query("thr:in-reply-to", $entry);
- if (!empty($inreplyto->item[0])) {
- foreach ($inreplyto->item[0]->attributes as $attributes) {
+ if (is_object($inreplyto->item(0))) {
+ foreach ($inreplyto->item(0)->attributes as $attributes) {
if ($attributes->name == "ref") {
$item["parent-uri"] = $attributes->textContent;
}