From 7c049abfda4423cd67570ba538f291682466c44a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Mon, 27 Jun 2022 11:37:34 +0200 Subject: [PATCH 1/2] Fixed: - Contact/User::isBlocked() needs to return boolean, but sometimes (strangely) a NULL can come from database, so let's cast it This tries to fix: TypeError: "Return value of Friendica\Model\Contact\User::isBlocked() must be of the type bool, null returned" --- src/Model/Contact/User.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Model/Contact/User.php b/src/Model/Contact/User.php index eb3d80eaa1..e0d6b1dcb2 100644 --- a/src/Model/Contact/User.php +++ b/src/Model/Contact/User.php @@ -183,7 +183,7 @@ class User if (!empty($cdata['public'])) { $public_contact = DBA::selectFirst('user-contact', ['blocked'], ['cid' => $cdata['public'], 'uid' => $uid]); if (DBA::isResult($public_contact)) { - $public_blocked = $public_contact['blocked']; + $public_blocked = (bool) $public_contact['blocked']; } } @@ -192,7 +192,7 @@ class User if (!empty($cdata['user'])) { $user_contact = DBA::selectFirst('contact', ['blocked'], ['id' => $cdata['user'], 'pending' => false]); if (DBA::isResult($user_contact)) { - $user_blocked = $user_contact['blocked']; + $user_blocked = (bool) $user_contact['blocked']; } } From 8e19998191c9b3a072844b4361fcc5ee83521c64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Mon, 27 Jun 2022 13:49:26 +0200 Subject: [PATCH 2/2] Fixes: - more "bool expected but null returned" errors --- src/Model/Contact.php | 6 +++--- src/Model/Contact/User.php | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Model/Contact.php b/src/Model/Contact.php index dd130a6416..63d4625c8a 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -1180,7 +1180,7 @@ class Contact $contact = self::getByURL($url, false, ['id', 'network', 'uri-id'], $uid); if (!empty($contact)) { - $contact_id = $contact["id"]; + $contact_id = $contact['id']; if (empty($update) && (!empty($contact['uri-id']) || is_bool($update))) { Logger::debug('Contact found', ['url' => $url, 'uid' => $uid, 'update' => $update, 'cid' => $contact_id]); @@ -1197,10 +1197,10 @@ class Contact $data = []; if (empty($default['network']) || $update) { - $data = Probe::uri($url, "", $uid); + $data = Probe::uri($url, '', $uid); // Take the default values when probing failed - if (!empty($default) && !in_array($data["network"], array_merge(Protocol::NATIVE_SUPPORT, [Protocol::PUMPIO]))) { + if (!empty($default) && !in_array($data['network'], array_merge(Protocol::NATIVE_SUPPORT, [Protocol::PUMPIO]))) { $data = array_merge($data, $default); } } elseif (!empty($default['network'])) { diff --git a/src/Model/Contact/User.php b/src/Model/Contact/User.php index e0d6b1dcb2..c656d1f003 100644 --- a/src/Model/Contact/User.php +++ b/src/Model/Contact/User.php @@ -246,7 +246,7 @@ class User if (!empty($cdata['public'])) { $public_contact = DBA::selectFirst('user-contact', ['ignored'], ['cid' => $cdata['public'], 'uid' => $uid]); if (DBA::isResult($public_contact)) { - $public_ignored = $public_contact['ignored']; + $public_ignored = (bool) $public_contact['ignored']; } } @@ -255,7 +255,7 @@ class User if (!empty($cdata['user'])) { $user_contact = DBA::selectFirst('contact', ['readonly'], ['id' => $cdata['user'], 'pending' => false]); if (DBA::isResult($user_contact)) { - $user_ignored = $user_contact['readonly']; + $user_ignored = (bool) $user_contact['readonly']; } } @@ -306,7 +306,7 @@ class User if (!empty($cdata['public'])) { $public_contact = DBA::selectFirst('user-contact', ['collapsed'], ['cid' => $cdata['public'], 'uid' => $uid]); if (DBA::isResult($public_contact)) { - $collapsed = $public_contact['collapsed']; + $collapsed = (bool) $public_contact['collapsed']; } }