From d54cf9cc210188639a0ea6490650a7654f2ccee7 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 28 Aug 2022 04:00:18 +0000 Subject: [PATCH] Avoid warnings/fatal errors --- src/Contact/Avatar.php | 2 +- src/Util/ParseUrl.php | 50 +++++++++++++++++++++--------------------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/Contact/Avatar.php b/src/Contact/Avatar.php index 1dd2f9cee6..d03a5f4e64 100644 --- a/src/Contact/Avatar.php +++ b/src/Contact/Avatar.php @@ -161,7 +161,7 @@ class Avatar $dirpath .= $part . '/'; if (!file_exists($dirpath)) { - if (!mkdir($dirpath, $dir_perm)) { + if (!@mkdir($dirpath, $dir_perm)) { Logger::warning('Directory could not be created', ['directory' => $dirpath]); } } elseif ((($old_perm = fileperms($dirpath) & 0777) != $dir_perm) && !chmod($dirpath, $dir_perm)) { diff --git a/src/Util/ParseUrl.php b/src/Util/ParseUrl.php index a0ff0f1773..d0b1682785 100644 --- a/src/Util/ParseUrl.php +++ b/src/Util/ParseUrl.php @@ -1040,17 +1040,17 @@ class ParseUrl } $content = JsonLD::fetchElement($jsonld, 'description'); - if (!empty($content)) { + if (!empty($content) && is_string($content)) { $jsonldinfo['text'] = trim($content); } $content = JsonLD::fetchElement($jsonld, 'image'); - if (!empty($content)) { + if (!empty($content) && is_string($content)) { $jsonldinfo['image'] = trim($content); } $content = JsonLD::fetchElement($jsonld, 'thumbnailUrl'); - if (!empty($content)) { + if (!empty($content) && is_string($content)) { $jsonldinfo['image'] = trim($content); } @@ -1075,22 +1075,22 @@ class ParseUrl $jsonldinfo = []; $content = JsonLD::fetchElement($jsonld, 'name'); - if (!empty($content)) { + if (!empty($content) && is_string($content)) { $jsonldinfo['publisher_name'] = trim($content); } $content = JsonLD::fetchElement($jsonld, 'description'); - if (!empty($content)) { + if (!empty($content) && is_string($content)) { $jsonldinfo['publisher_description'] = trim($content); } $content = JsonLD::fetchElement($jsonld, 'url'); - if (!empty($content)) { + if (!empty($content) && is_string($content)) { $jsonldinfo['publisher_url'] = trim($content); } $content = JsonLD::fetchElement($jsonld, 'thumbnailUrl'); - if (!empty($content)) { + if (!empty($content) && is_string($content)) { $jsonldinfo['image'] = trim($content); } @@ -1114,32 +1114,32 @@ class ParseUrl $jsonldinfo = []; $content = JsonLD::fetchElement($jsonld, 'name'); - if (!empty($content)) { + if (!empty($content) && is_string($content)) { $jsonldinfo['publisher_name'] = trim($content); } $content = JsonLD::fetchElement($jsonld, 'description'); - if (!empty($content)) { + if (!empty($content) && is_string($content)) { $jsonldinfo['publisher_description'] = trim($content); } $content = JsonLD::fetchElement($jsonld, 'url'); - if (!empty($content)) { + if (!empty($content) && is_string($content)) { $jsonldinfo['publisher_url'] = trim($content); } $content = JsonLD::fetchElement($jsonld, 'logo', 'url', '@type', 'ImageObject'); - if (!empty($content)) { + if (!empty($content) && is_string($content)) { $jsonldinfo['publisher_img'] = trim($content); } $content = JsonLD::fetchElement($jsonld, 'brand', 'name', '@type', 'Organization'); - if (!empty($content)) { + if (!empty($content) && is_string($content)) { $jsonldinfo['publisher_name'] = trim($content); } $content = JsonLD::fetchElement($jsonld, 'brand', 'url', '@type', 'Organization'); - if (!empty($content)) { + if (!empty($content) && is_string($content)) { $jsonldinfo['publisher_url'] = trim($content); } @@ -1161,12 +1161,12 @@ class ParseUrl $jsonldinfo = []; $content = JsonLD::fetchElement($jsonld, 'name'); - if (!empty($content)) { + if (!empty($content) && is_string($content)) { $jsonldinfo['author_name'] = trim($content); } $content = JsonLD::fetchElement($jsonld, 'description'); - if (!empty($content)) { + if (!empty($content) && is_string($content)) { $jsonldinfo['author_description'] = trim($content); } @@ -1176,7 +1176,7 @@ class ParseUrl } $content = JsonLD::fetchElement($jsonld, 'url'); - if (!empty($content)) { + if (!empty($content) && is_string($content)) { $jsonldinfo['author_url'] = trim($content); } @@ -1207,22 +1207,22 @@ class ParseUrl $media = []; $content = JsonLD::fetchElement($jsonld, 'caption'); - if (!empty($content)) { + if (!empty($content) && is_string($content)) { $media['caption'] = trim($content); } $content = JsonLD::fetchElement($jsonld, 'url'); - if (!empty($content)) { + if (!empty($content) && is_string($content)) { $media['url'] = trim($content); } $content = JsonLD::fetchElement($jsonld, 'mainEntityOfPage'); - if (!empty($content)) { + if (!empty($content) && is_string($content)) { $media['main'] = Strings::compareLink($content, $siteinfo['url']); } $content = JsonLD::fetchElement($jsonld, 'description'); - if (!empty($content)) { + if (!empty($content) && is_string($content)) { $media['description'] = trim($content); } @@ -1232,27 +1232,27 @@ class ParseUrl } $content = JsonLD::fetchElement($jsonld, 'contentUrl'); - if (!empty($content)) { + if (!empty($content) && is_string($content)) { $media['content'] = trim($content); } $content = JsonLD::fetchElement($jsonld, 'embedUrl'); - if (!empty($content)) { + if (!empty($content) && is_string($content)) { $media['embed'] = trim($content); } $content = JsonLD::fetchElement($jsonld, 'height'); - if (!empty($content)) { + if (!empty($content) && is_string($content)) { $media['height'] = trim($content); } $content = JsonLD::fetchElement($jsonld, 'width'); - if (!empty($content)) { + if (!empty($content) && is_string($content)) { $media['width'] = trim($content); } $content = JsonLD::fetchElement($jsonld, 'image'); - if (!empty($content)) { + if (!empty($content) && is_string($content)) { $media['image'] = trim($content); }