Merge pull request #11673 from Quix0r/bugs/returned-type-array-bool

Fixed: ?? didn't work here as bool won't be seen as null
This commit is contained in:
Hypolite Petovan 2022-06-22 13:29:39 -04:00 committed by GitHub
commit c824ba43d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 7 deletions

View File

@ -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 (($imgdata) && substr($imgdata['mime'], 0, 6) == 'image/') {
$post['type'] = 'photo';
$post['image'] = $pictures[0][1];
$post['preview'] = $pictures[0][2];

View File

@ -192,7 +192,7 @@ class Media
if (($media['type'] == self::IMAGE) || ($filetype == 'image')) {
$imagedata = Images::getInfoFromURLCached($media['url']);
if (!empty($imagedata)) {
if ($imagedata) {
$media['mimetype'] = $imagedata['mime'];
$media['size'] = $imagedata['size'];
$media['width'] = $imagedata[0];
@ -202,7 +202,7 @@ class Media
}
if (!empty($media['preview'])) {
$imagedata = Images::getInfoFromURLCached($media['preview']);
if (!empty($imagedata)) {
if ($imagedata) {
$media['preview-width'] = $imagedata[0];
$media['preview-height'] = $imagedata[1];
}

View File

@ -1388,6 +1388,7 @@ class OStatus
}
}
break;
case 'video':
$attributes = [
'rel' => 'enclosure',
@ -1398,7 +1399,9 @@ class OStatus
];
XML::addElement($doc, $root, 'link', '', $attributes);
break;
default:
Logger::warning('Unsupported type', ['type' => $siteinfo['type'], 'url' => $siteinfo['url']]);
break;
}

View File

@ -247,7 +247,7 @@ class Images
$data['size'] = $filesize;
}
return $data ?? [];
return is_array($data) ? $data : [];
}
/**

View File

@ -543,12 +543,15 @@ class ParseUrl
{
if (!empty($siteinfo['images'])) {
array_walk($siteinfo['images'], function (&$image) use ($page_url) {
// According to the specifications someone could place a picture url into the content field as well.
// But this doesn't seem to happen in the wild, so we don't cover it here.
/*
* According to the specifications someone could place a picture
* URL into the content field as well. But this doesn't seem to
* happen in the wild, so we don't cover it here.
*/
if (!empty($image['url'])) {
$image['url'] = self::completeUrl($image['url'], $page_url);
$photodata = Images::getInfoFromURLCached($image['url']);
if (!empty($photodata) && ($photodata[0] > 50) && ($photodata[1] > 50)) {
if (($photodata) && ($photodata[0] > 50) && ($photodata[1] > 50)) {
$image['src'] = $image['url'];
$image['width'] = $photodata[0];
$image['height'] = $photodata[1];