From fe74db631139f4b387f14ae04b967a4658c0edcb Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Sun, 24 Feb 2019 15:15:25 +0100 Subject: [PATCH 1/2] Fixing https://github.com/friendica/friendica/issues/6338#issuecomment-458030934 --- mod/display.php | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/mod/display.php b/mod/display.php index 2e931e068..6723a77e9 100644 --- a/mod/display.php +++ b/mod/display.php @@ -19,10 +19,10 @@ use Friendica\Model\Contact; use Friendica\Model\Group; use Friendica\Model\Item; use Friendica\Model\Profile; +use Friendica\Module\Objects; use Friendica\Protocol\ActivityPub; use Friendica\Protocol\DFRN; use Friendica\Util\Strings; -use Friendica\Module\Objects; function display_init(App $a) { @@ -283,22 +283,25 @@ function display_content(App $a, $update = false, $update_uid = 0) $is_remote_contact = false; $item_uid = local_user(); - $parent = Item::selectFirst(['uid'], ['uri' => $item_parent_uri, 'wall' => true]); - if (DBA::isResult($parent)) { - $a->profile['uid'] = defaults($a->profile, 'uid', $parent['uid']); - $a->profile['profile_uid'] = defaults($a->profile, 'profile_uid', $parent['uid']); - $is_remote_contact = Contact::isFollower(remote_user(), $a->profile['profile_uid']); - } + if (isset($item_parent_uri)) { + $parent = Item::selectFirst(['uid'], ['uri' => $item_parent_uri, 'wall' => true]); + if (DBA::isResult($parent)) { + $a->profile['uid'] = defaults($a->profile, 'uid', $parent['uid']); + $a->profile['profile_uid'] = defaults($a->profile, 'profile_uid', $parent['uid']); + $is_remote_contact = Contact::isFollower(remote_user(), $a->profile['profile_uid']); - if ($is_remote_contact) { - $cdata = Contact::getPublicAndUserContacID(remote_user(), $a->profile['profile_uid']); - if (!empty($cdata['user'])) { - $groups = Group::getIdsByContactId($cdata['user']); - $remote_cid = $cdata['user']; - $item_uid = $parent['uid']; + if ($is_remote_contact) { + $cdata = Contact::getPublicAndUserContacID(remote_user(), $a->profile['profile_uid']); + if (!empty($cdata['user'])) { + $groups = Group::getIdsByContactId($cdata['user']); + $remote_cid = $cdata['user']; + $item_uid = $parent['uid']; + } + } } } + $page_contact = DBA::selectFirst('contact', [], ['self' => true, 'uid' => $a->profile['uid']]); if (DBA::isResult($page_contact)) { $a->page_contact = $page_contact; From 5b932867c3f62153f590c15f18cc87aae5e69fd7 Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Sun, 24 Feb 2019 15:22:14 +0100 Subject: [PATCH 2/2] Fixing https://github.com/friendica/friendica/issues/6338#issuecomment-466749280 --- src/Protocol/PortableContact.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Protocol/PortableContact.php b/src/Protocol/PortableContact.php index 7900ff540..b9c1533e6 100644 --- a/src/Protocol/PortableContact.php +++ b/src/Protocol/PortableContact.php @@ -505,8 +505,15 @@ class PortableContact $last_updated = ""; foreach ($entries as $entry) { - $published = DateTimeFormat::utc($xpath->query('atom:published/text()', $entry)->item(0)->nodeValue); - $updated = DateTimeFormat::utc($xpath->query('atom:updated/text()' , $entry)->item(0)->nodeValue); + $published_item = $xpath->query('atom:published/text()', $entry)->item(0); + $updated_item = $xpath->query('atom:updated/text()' , $entry)->item(0); + $published = isset($published_item->nodeValue) ? DateTimeFormat::utc($published_item->nodeValue) : null; + $updated = isset($updated_item->nodeValue) ? DateTimeFormat::utc($updated_item->nodeValue) : null; + + if (!isset($published) || !isset($updated)) { + Logger::notice('Invalid entry for XPath.', ['entry' => $entry, 'profile' => $profile]); + continue; + } if ($last_updated < $published) { $last_updated = $published;