From 412a0b3e1c39e296ca39938a75e7544c9f373bc3 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Mon, 10 May 2021 21:32:03 -0400 Subject: [PATCH 1/5] Ensure JsonD data passed to ParseURL::parseParts is an array - Address https://github.com/friendica/friendica/issues/10167#issuecomment-827894961 --- src/Util/ParseUrl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Util/ParseUrl.php b/src/Util/ParseUrl.php index 5dee4d3a2..d5c9f02ad 100644 --- a/src/Util/ParseUrl.php +++ b/src/Util/ParseUrl.php @@ -695,7 +695,7 @@ class ParseUrl { if (!empty($jsonld['@graph']) && is_array($jsonld['@graph'])) { foreach ($jsonld['@graph'] as $part) { - if (!empty($part)) { + if (!empty($part) && is_array($part)) { $siteinfo = self::parseParts($siteinfo, $part); } } From 115da7a708cd7c49f20b88018ab70fad23566667 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Mon, 10 May 2021 21:42:59 -0400 Subject: [PATCH 2/5] Fix PHP 8 Fatal Error with already closed statement in mod/ping - Address https://github.com/friendica/friendica/issues/10167#issuecomment-828941639 --- mod/ping.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mod/ping.php b/mod/ping.php index 6efa889c7..64c947e2c 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -139,7 +139,7 @@ function ping_init(App $a) local_user(), Verb::getID(Activity::FOLLOW)]; $items = Post::selectForUser(local_user(), ['wall', 'uid', 'uri-id'], $condition); if (DBA::isResult($items)) { - $items_unseen = Post::toArray($items); + $items_unseen = Post::toArray($items, false); $arr = ['items' => $items_unseen]; Hook::callAll('network_ping', $arr); From 9ef9fc7c14991cc69082b9b763e30a9473329546 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Mon, 10 May 2021 21:50:42 -0400 Subject: [PATCH 3/5] Skip URL-less mention terms in Object\Post::getDefaultText - Address https://github.com/friendica/friendica/issues/10167#issuecomment-830859710 - Added logging to troubleshoot deeper issue --- src/Object/Post.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Object/Post.php b/src/Object/Post.php index 6973fd236..ba8c709de 100644 --- a/src/Object/Post.php +++ b/src/Object/Post.php @@ -887,8 +887,13 @@ class Post $terms = Tag::getByURIId($item['uri-id'], [Tag::MENTION, Tag::IMPLICIT_MENTION, Tag::EXCLUSIVE_MENTION]); foreach ($terms as $term) { + if (!$term['url']) { + DI::logger()->warning('Mention term with no URL', ['term' => $term]); + continue; + } + $profile = Contact::getByURL($term['url'], false, ['addr', 'contact-type']); - if (!empty($profile['addr']) && ((($profile['contact-type'] ?? '') ?: Contact::TYPE_UNKNOWN) != Contact::TYPE_COMMUNITY) && + if (!empty($profile['addr']) && (($profile['contact-type'] ?? Contact::TYPE_UNKNOWN) != Contact::TYPE_COMMUNITY) && ($profile['addr'] != $owner['addr']) && !strstr($text, $profile['addr'])) { $text .= '@' . $profile['addr'] . ' '; } From 48ac619599d5c737a92786b8156979fea25aba49 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Mon, 10 May 2021 21:52:26 -0400 Subject: [PATCH 4/5] Check unparseURL parameter type in APContact::getByURL - Address https://github.com/friendica/friendica/issues/10167#issuecomment-832421258 --- src/Model/APContact.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Model/APContact.php b/src/Model/APContact.php index 863496dbb..cc84df4a5 100644 --- a/src/Model/APContact.php +++ b/src/Model/APContact.php @@ -235,7 +235,7 @@ class APContact unset($parts['path']); if (empty($apcontact['addr'])) { - if (!empty($apcontact['nick'])) { + if (!empty($apcontact['nick']) && is_array($parts)) { $apcontact['addr'] = $apcontact['nick'] . '@' . str_replace('//', '', Network::unparseURL($parts)); } else { $apcontact['addr'] = ''; From 10e56309887faa6f726f62495fd67efd624440ac Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Mon, 10 May 2021 22:03:51 -0400 Subject: [PATCH 5/5] Don't assume $a->contact is populated in Object\Post::getCommentBox - Address https://github.com/friendica/friendica/issues/10167#issuecomment-837238584 - This might reveal some side-effect --- src/Object/Post.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Object/Post.php b/src/Object/Post.php index ba8c709de..2e6eb1bf6 100644 --- a/src/Object/Post.php +++ b/src/Object/Post.php @@ -950,9 +950,9 @@ class Post '$qcomment' => $qcomment, '$default' => $default_text, '$profile_uid' => $uid, - '$mylink' => DI::baseUrl()->remove($a->contact['url']), + '$mylink' => DI::baseUrl()->remove($a->contact['url'] ?? ''), '$mytitle' => DI::l10n()->t('This is you'), - '$myphoto' => DI::baseUrl()->remove($a->contact['thumb']), + '$myphoto' => DI::baseUrl()->remove($a->contact['thumb'] ?? ''), '$comment' => DI::l10n()->t('Comment'), '$submit' => DI::l10n()->t('Submit'), '$loading' => DI::l10n()->t('Loading...'),