From: Hypolite Petovan Date: Mon, 9 Mar 2020 15:12:33 +0000 (-0400) Subject: Ensure non-NULL values in $data array in Contact::updateAvatar X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=89534b5be37dd817e93b51892d8e6dc6d036a7b8;p=friendica.git Ensure non-NULL values in $data array in Contact::updateAvatar - Throw Exception instead of returning false if contact doesn't exist - Address https://github.com/friendica/friendica/issues/7998#issuecomment-596271239 --- diff --git a/src/Model/Contact.php b/src/Model/Contact.php index 0e542316db..f60a362c57 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -1913,17 +1913,23 @@ class Contact * * @return array Returns array of the different avatar sizes * @throws HTTPException\InternalServerErrorException + * @throws HTTPException\NotFoundException * @throws \ImagickException */ public static function updateAvatar($avatar, $uid, $cid, $force = false) { $contact = DBA::selectFirst('contact', ['avatar', 'photo', 'thumb', 'micro', 'nurl'], ['id' => $cid, 'self' => false]); if (!DBA::isResult($contact)) { - return false; - } else { - $data = [$contact["photo"], $contact["thumb"], $contact["micro"]]; + Logger::error('Contact not found', ['cid' => $cid]); + throw new HTTPException\NotFoundException('Contact not found'); } + $data = [ + $contact['photo'] ?? '', + $contact['thumb'] ?? '', + $contact['micro'] ?? '', + ]; + foreach ($data as $image_uri) { $image_rid = Photo::ridFromURI($image_uri); if ($image_rid && !Photo::exists(['resource-id' => $image_rid, 'uid' => $uid])) {