From 5d3248d57b53efeb0ab862a6e0bb2615b3253819 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 11 Dec 2022 16:48:36 +0000 Subject: [PATCH] Handle some fatal errors --- src/Factory/Api/Mastodon/Status.php | 7 +++++-- src/Util/Images.php | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Factory/Api/Mastodon/Status.php b/src/Factory/Api/Mastodon/Status.php index 94b42ce79c..18701bb661 100644 --- a/src/Factory/Api/Mastodon/Status.php +++ b/src/Factory/Api/Mastodon/Status.php @@ -199,8 +199,11 @@ class Status extends BaseFactory } } - $item['body'] = $this->contentItem->addSharedPost($item); - $item['raw-body'] = $this->contentItem->addSharedPost($item, $item['raw-body']); + $item['body'] = $this->contentItem->addSharedPost($item); + + if (!is_null($item['raw-body'])) { + $item['raw-body'] = $this->contentItem->addSharedPost($item, $item['raw-body']); + } if ($is_reshare) { $reshare = $this->createFromUriId($uriId, $uid, false)->toArray(); diff --git a/src/Util/Images.php b/src/Util/Images.php index 533feec844..a6a9f4f7db 100644 --- a/src/Util/Images.php +++ b/src/Util/Images.php @@ -247,8 +247,11 @@ class Images if ($data) { $image = new Image($img_str); - $data['blurhash'] = $image->getBlurHash(); - $data['size'] = $filesize; + if ($image->isValid()) { + $data['blurhash'] = $image->getBlurHash(); + } + + $data['size'] = $filesize; } return is_array($data) ? $data : [];