]> git.mxchange.org Git - friendica.git/commitdiff
Images::getInfoFromURL[Cached]() will both return empty arrays on error and
authorRoland Häder <roland@mxchange.org>
Wed, 22 Jun 2022 15:18:39 +0000 (17:18 +0200)
committerRoland Häder <roland@mxchange.org>
Wed, 22 Jun 2022 15:20:59 +0000 (17:20 +0200)
that needs to be reflected here, too.

src/Content/Text/BBCode.php
src/Protocol/OStatus.php

index b4b8e481936860e9f9a5a00f98c18eab194753cc..1c6f11c2f3f25834ee7a361ac5262b8a9f2e8b0d 100644 (file)
@@ -111,7 +111,7 @@ class BBCode
 
                                        $picturedata = Images::getInfoFromURLCached($matches[1]);
 
-                                       if ($picturedata) {
+                                       if (!empty($picturedata)) {
                                                if (($picturedata[0] >= 500) && ($picturedata[0] >= $picturedata[1])) {
                                                        $post['image'] = $matches[1];
                                                } else {
@@ -320,7 +320,7 @@ class BBCode
                                                $post['text'] = trim(str_replace($pictures[0][0], '', $body));
                                        } else {
                                                $imgdata = Images::getInfoFromURLCached($pictures[0][1]);
-                                               if ($imgdata && substr($imgdata['mime'], 0, 6) == 'image/') {
+                                               if (!empty($imgdata) && substr($imgdata['mime'], 0, 6) == 'image/') {
                                                        $post['type'] = 'photo';
                                                        $post['image'] = $pictures[0][1];
                                                        $post['preview'] = $pictures[0][2];
index d410fa4f7150a67384e458ba788d2083f265ff84..be86c13be7eafc02981b0ea231f52452b1f1ae07 100644 (file)
@@ -1377,7 +1377,7 @@ class OStatus
                        case 'photo':
                                if (!empty($siteinfo['image'])) {
                                        $imgdata = Images::getInfoFromURLCached($siteinfo['image']);
-                                       if ($imgdata) {
+                                       if (!empty($imgdata)) {
                                                $attributes = [
                                                        'rel' => 'enclosure',
                                                        'href' => $siteinfo['image'],
@@ -1388,6 +1388,7 @@ class OStatus
                                        }
                                }
                                break;
+
                        case 'video':
                                $attributes = [
                                        'rel' => 'enclosure',
@@ -1398,13 +1399,15 @@ class OStatus
                                ];
                                XML::addElement($doc, $root, 'link', '', $attributes);
                                break;
+
                        default:
+                               Logger::warning('Unsupported type', ['type' => $siteinfo['type'], 'url' => $siteinfo['url']]);
                                break;
                }
 
                if (!DI::config()->get('system', 'ostatus_not_attach_preview') && ($siteinfo['type'] != 'photo') && isset($siteinfo['image'])) {
                        $imgdata = Images::getInfoFromURLCached($siteinfo['image']);
-                       if ($imgdata) {
+                       if (!empty($imgdata)) {
                                $attributes = [
                                        'rel' => 'enclosure',
                                        'href' => $siteinfo['image'],