From e97231683ad4f8e613e23a410792b74ed95e0726 Mon Sep 17 00:00:00 2001 From: Art4 Date: Sat, 16 Nov 2024 17:16:26 +0000 Subject: [PATCH] fix erros in Util namespace --- src/Util/EMailer/NotifyMailBuilder.php | 6 +++--- src/Util/HTTPSignature.php | 4 ---- src/Util/Images.php | 6 +++--- src/Util/ParseUrl.php | 2 +- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/Util/EMailer/NotifyMailBuilder.php b/src/Util/EMailer/NotifyMailBuilder.php index 57fe544127..d53715a83e 100644 --- a/src/Util/EMailer/NotifyMailBuilder.php +++ b/src/Util/EMailer/NotifyMailBuilder.php @@ -109,9 +109,9 @@ class NotifyMailBuilder extends MailBuilder public function withPhoto(string $image, string $link, string $name) { $this->photo = [ - 'image' => $image ?? '', - 'link' => $link ?? '', - 'name' => $name ?? '', + 'image' => $image, + 'link' => $link, + 'name' => $name, ]; return $this; diff --git a/src/Util/HTTPSignature.php b/src/Util/HTTPSignature.php index d7679abd1f..cf8971bcbe 100644 --- a/src/Util/HTTPSignature.php +++ b/src/Util/HTTPSignature.php @@ -478,10 +478,6 @@ class HTTPSignature return []; } - if (empty($curlResult)) { - return []; - } - if (!$curlResult->isSuccess() || empty($curlResult->getBodyString())) { Logger::debug('Fetching was unsuccessful', ['url' => $request, 'return-code' => $curlResult->getReturnCode(), 'error-number' => $curlResult->getErrorNumber(), 'error' => $curlResult->getError()]); return []; diff --git a/src/Util/Images.php b/src/Util/Images.php index 675f034b9c..62e22ef2f8 100644 --- a/src/Util/Images.php +++ b/src/Util/Images.php @@ -308,13 +308,13 @@ class Images $data = DI::cache()->get($cacheKey); - if (empty($data) || !is_array($data)) { + if (!is_array($data)) { $data = self::getInfoFromURL($url, $ocr); DI::cache()->set($cacheKey, $data); } - return $data ?? []; + return $data; } /** @@ -370,7 +370,7 @@ class Images if ($image->isValid()) { $data['blurhash'] = $image->getBlurHash(); - + if ($ocr) { $media = ['img_str' => $img_str]; Hook::callAll('ocr-detection', $media); diff --git a/src/Util/ParseUrl.php b/src/Util/ParseUrl.php index 4238499bab..d0377e02ac 100644 --- a/src/Util/ParseUrl.php +++ b/src/Util/ParseUrl.php @@ -1087,7 +1087,7 @@ class ParseUrl $content = JsonLD::fetchElement($jsonld, 'logo', 'url', '@type', 'ImageObject'); if (!empty($content) && is_string($content)) { $jsonldinfo['publisher_img'] = trim($content); - } elseif (!empty($content) && is_array($content)) { + } elseif (is_array($content) && array_key_exists(0, $content)) { $jsonldinfo['publisher_img'] = trim($content[0]); }