From 56c00ea42d3f642481fd8159cddf7431bd8dd71a Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 10 Aug 2021 03:50:43 +0000 Subject: [PATCH] Handles PHP Notice: Undefined index: addr in src/Protocol/Diaspora.php on line 3091 --- src/Protocol/Diaspora.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/Protocol/Diaspora.php b/src/Protocol/Diaspora.php index 485e5a7846..b38e0506b9 100644 --- a/src/Protocol/Diaspora.php +++ b/src/Protocol/Diaspora.php @@ -3082,6 +3082,11 @@ class Diaspora if (!empty($fcontact)) { $pubkey = $fcontact['pubkey']; } + } else { + // The "addr" field should always be filled. + // If this isn't the case, it will raise a notice some lines later. + // And in the log we will see where it came from and we can handle it there. + Logger::notice('Empty addr', ['contact' => $contact ?? [], 'callstack' => System::callstack(20)]); } $envelope = self::buildMessage($msg, $owner, $contact, $owner['uprvkey'], $pubkey, $public_batch); @@ -3988,13 +3993,7 @@ class Diaspora } if (!$recips) { - $recips = q( - "SELECT `id`,`name`,`network`,`pubkey`,`notify` FROM `contact` WHERE `network` = '%s' - AND `uid` = %d AND `rel` != %d", - DBA::escape(Protocol::DIASPORA), - intval($uid), - intval(Contact::SHARING) - ); + $recips = DBA::selectToArray('contact', [], ['network' => Protocol::DIASPORA, 'uid' => $uid, 'rel' => [Contact::FOLLOWER, Contact::FRIEND]]); } if (!$recips) {