From: Matthew Exon Date: Sat, 11 Jan 2020 15:00:02 +0000 (+0100) Subject: Implement code review from nupplaphil X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=5d0a3be4f698d4861e7aabd9237484ee0e9644e7;p=friendica.git Implement code review from nupplaphil --- diff --git a/src/Model/Contact.php b/src/Model/Contact.php index 7722b69909..e6c00b1e3c 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -1899,7 +1899,7 @@ class Contact foreach ($data as $image_uri) { $image_rid = Photo::ridFromURI($image_uri); if ($image_rid && !Photo::exists(['resource-id' => $image_rid, 'uid' => $uid])) { - Logger::info('Regenerating avatar for contact uid ' . $uid . ' cid ' . $cid . ' missing photo ' . $image_rid . ' avatar ' . $contact['avatar']); + Logger::info('Regenerating avatar', ['contact uid' => $uid, 'cid' => $cid, 'missing photo' => $image_rid, 'avatar' => $contact['avatar']]); $force = true; } } diff --git a/src/Model/Mail.php b/src/Model/Mail.php index da72d7d51f..292d797b85 100644 --- a/src/Model/Mail.php +++ b/src/Model/Mail.php @@ -216,7 +216,7 @@ class Mail if (count($images)) { foreach ($images as $image) { $image_rid = Photo::ridFromURI($image); - if ($image_rid) { + if (!empty($image_rid)) { Photo::update(['allow-cid' => '<' . $recipient . '>'], ['resource-id' => $image_rid, 'album' => 'Wall Photos', 'uid' => local_user()]); } } diff --git a/src/Model/Photo.php b/src/Model/Photo.php index 801ef25fba..8b65c0d0e0 100644 --- a/src/Model/Photo.php +++ b/src/Model/Photo.php @@ -605,12 +605,12 @@ class Photo public static function ridFromURI($image_uri) { if (!stristr($image_uri, DI::baseUrl() . '/photo/')) { - return; + return ''; } $image_uri = substr($image_uri, strrpos($image_uri, '/') + 1); $image_uri = substr($image_uri, 0, strpos($image_uri, '-')); if (!strlen($image_uri)) { - return; + return ''; } return $image_uri; } @@ -642,7 +642,7 @@ class Photo foreach ($images as $image) { $image_rid = self::ridFromURI($image); - if (!$image_rid) { + if (empty($image_rid)) { continue; }