From 150c0e0750cd4aca38d450e896fcd2fccbbe164b Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Tue, 29 Nov 2022 19:31:16 -0500 Subject: [PATCH 1/4] Address some PHP 8.1 deprecation notices - Replace a strstr call by strpos in Model\APContact - Simplify conditions in Protocol\DFRN - Address part of https://github.com/friendica/friendica/issues/12011#issuecomment-1331012289 --- src/Model/APContact.php | 4 ++-- src/Navigation/Notifications/ValueObject/Introduction.php | 1 + src/Protocol/DFRN.php | 8 ++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Model/APContact.php b/src/Model/APContact.php index 3b568f39f..67ce2b66b 100644 --- a/src/Model/APContact.php +++ b/src/Model/APContact.php @@ -305,8 +305,8 @@ class APContact $apcontact['pubkey'] = null; if (!empty($compacted['w3id:publicKey'])) { - $apcontact['pubkey'] = trim(JsonLD::fetchElement($compacted['w3id:publicKey'], 'w3id:publicKeyPem', '@value')); - if (strstr($apcontact['pubkey'], 'RSA ')) { + $apcontact['pubkey'] = trim(JsonLD::fetchElement($compacted['w3id:publicKey'], 'w3id:publicKeyPem', '@value') ?? ''); + if (strpos($apcontact['pubkey'], 'RSA ') !== false) { $apcontact['pubkey'] = Crypto::rsaToPem($apcontact['pubkey']); } } diff --git a/src/Navigation/Notifications/ValueObject/Introduction.php b/src/Navigation/Notifications/ValueObject/Introduction.php index cb27b3888..da664ce8e 100644 --- a/src/Navigation/Notifications/ValueObject/Introduction.php +++ b/src/Navigation/Notifications/ValueObject/Introduction.php @@ -226,6 +226,7 @@ class Introduction implements \JsonSerializable /** * @inheritDoc */ + #[\ReturnTypeWillChange] public function jsonSerialize() { return $this->toArray(); diff --git a/src/Protocol/DFRN.php b/src/Protocol/DFRN.php index da4db5d9a..a86cf2094 100644 --- a/src/Protocol/DFRN.php +++ b/src/Protocol/DFRN.php @@ -538,7 +538,7 @@ class DFRN XML::addElement($doc, $author, 'poco:utcOffset', DateTimeFormat::timezoneNow($profile['timezone'], 'P')); - if (trim($profile['homepage']) != '') { + if (trim($profile['homepage'])) { $urls = $doc->createElement('poco:urls'); XML::addElement($doc, $urls, 'poco:type', 'homepage'); XML::addElement($doc, $urls, 'poco:value', $profile['homepage']); @@ -546,7 +546,7 @@ class DFRN $author->appendChild($urls); } - if (trim($profile['pub_keywords']) != '') { + if (trim($profile['pub_keywords'] ?? '')) { $keywords = explode(',', $profile['pub_keywords']); foreach ($keywords as $keyword) { @@ -554,7 +554,7 @@ class DFRN } } - if (trim($profile['xmpp']) != '') { + if (trim($profile['xmpp'])) { $ims = $doc->createElement('poco:ims'); XML::addElement($doc, $ims, 'poco:type', 'xmpp'); XML::addElement($doc, $ims, 'poco:value', $profile['xmpp']); @@ -562,7 +562,7 @@ class DFRN $author->appendChild($ims); } - if (trim($profile['locality'] . $profile['region'] . $profile['country-name']) != '') { + if (trim($profile['locality'] . $profile['region'] . $profile['country-name'])) { $element = $doc->createElement('poco:address'); XML::addElement($doc, $element, 'poco:formatted', Profile::formatLocation($profile)); From a01cdccb05b2db46a43272a0bfd6c7bab8787118 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 30 Nov 2022 09:28:27 +0000 Subject: [PATCH 2/4] Check that an auto reshare is only done on the expected contact --- src/Model/Item.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Model/Item.php b/src/Model/Item.php index cb998c0fd..89925c532 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -2271,6 +2271,11 @@ class Item return; } + $cdata = Contact::getPublicAndUserContactID($item['author-id'], $item['uid']); + if (empty($cdata['user']) || ($cdata['user'] != $item['contact-id'])) { + return; + } + if (!DBA::exists('contact', ['id' => $item['contact-id'], 'remote_self' => Contact::MIRROR_NATIVE_RESHARE])) { return; } From da93373e8d959e112639c0c5c3ccbc715aac0dd1 Mon Sep 17 00:00:00 2001 From: Matthias Moritz Date: Wed, 30 Nov 2022 12:15:58 +0100 Subject: [PATCH 3/4] Fix #12262 - shared friendica posts are filtered on status page Native shares from the same Instance (or maybe all Friendica instances) were filtered out from the users home. With this commit they now appear on the users Profile/Status --- src/Module/Profile/Status.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Module/Profile/Status.php b/src/Module/Profile/Status.php index 951a0e327..5dae349d7 100644 --- a/src/Module/Profile/Status.php +++ b/src/Module/Profile/Status.php @@ -174,8 +174,8 @@ class Status extends BaseProfile $condition = DBA::mergeConditions($condition, ["((`gravity` = ? AND `wall`) OR (`gravity` = ? AND `vid` = ? AND `origin` - AND `thr-parent-id` IN (SELECT `uri-id` FROM `post` WHERE `gravity` = ? AND `network` = ?)))", - Item::GRAVITY_PARENT, Item::GRAVITY_ACTIVITY, Verb::getID(Activity::ANNOUNCE), Item::GRAVITY_PARENT, Protocol::ACTIVITYPUB]); + AND `thr-parent-id` IN (SELECT `uri-id` FROM `post` WHERE `gravity` = ? )))", + Item::GRAVITY_PARENT, Item::GRAVITY_ACTIVITY, Verb::getID(Activity::ANNOUNCE), Item::GRAVITY_PARENT]); $condition = DBA::mergeConditions($condition, ['uid' => $profile['uid'], 'network' => Protocol::FEDERATED, 'visible' => true, 'deleted' => false]); From 71f4dd0d205533930f9d3d1bc115d7216285d508 Mon Sep 17 00:00:00 2001 From: Matthias Moritz Date: Wed, 30 Nov 2022 13:19:31 +0100 Subject: [PATCH 4/4] Update Status.php Instead of removing AP, added Protocol::DFRN to the list of networks. --- src/Module/Profile/Status.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Module/Profile/Status.php b/src/Module/Profile/Status.php index 5dae349d7..6543ea195 100644 --- a/src/Module/Profile/Status.php +++ b/src/Module/Profile/Status.php @@ -174,8 +174,8 @@ class Status extends BaseProfile $condition = DBA::mergeConditions($condition, ["((`gravity` = ? AND `wall`) OR (`gravity` = ? AND `vid` = ? AND `origin` - AND `thr-parent-id` IN (SELECT `uri-id` FROM `post` WHERE `gravity` = ? )))", - Item::GRAVITY_PARENT, Item::GRAVITY_ACTIVITY, Verb::getID(Activity::ANNOUNCE), Item::GRAVITY_PARENT]); + AND `thr-parent-id` IN (SELECT `uri-id` FROM `post` WHERE `gravity` = ? AND `network` IN (?, ?))))", + Item::GRAVITY_PARENT, Item::GRAVITY_ACTIVITY, Verb::getID(Activity::ANNOUNCE), Item::GRAVITY_PARENT, Protocol::ACTIVITYPUB, Protocol::DFRN]); $condition = DBA::mergeConditions($condition, ['uid' => $profile['uid'], 'network' => Protocol::FEDERATED, 'visible' => true, 'deleted' => false]);