From 914d4506e24ae04760a711f19f27e2a6f274bab1 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 5 Dec 2023 22:33:45 +0000 Subject: [PATCH] Exception handling added --- src/Content/Post/Factory/PostMedia.php | 2 +- src/Content/Post/Repository/PostMedia.php | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Content/Post/Factory/PostMedia.php b/src/Content/Post/Factory/PostMedia.php index 864786569f..dfebfd4874 100644 --- a/src/Content/Post/Factory/PostMedia.php +++ b/src/Content/Post/Factory/PostMedia.php @@ -49,7 +49,7 @@ class PostMedia extends BaseFactory implements ICanCreateFromTableRow { return new Entity\PostMedia( $row['uri-id'], - UtilNetwork::createUriFromString($row['url']) ?: '', + UtilNetwork::createUriFromString($row['url']), $row['type'], $this->mimeTypeFactory->createFromContentType($row['mimetype']), $row['media-uri-id'], diff --git a/src/Content/Post/Repository/PostMedia.php b/src/Content/Post/Repository/PostMedia.php index 405d9eb86b..70441e0c9d 100644 --- a/src/Content/Post/Repository/PostMedia.php +++ b/src/Content/Post/Repository/PostMedia.php @@ -45,7 +45,11 @@ class PostMedia extends BaseRepository $Entities = new Collection\PostMedias(); foreach ($rows as $fields) { - $Entities[] = $this->factory->createFromTableRow($fields); + try { + $Entities[] = $this->factory->createFromTableRow($fields); + } catch (\Exception $e) { + $this->logger->warning('Invalid media row', ['code' => $e->getCode(), 'message' => $e->getMessage(), 'fields' => $fields]); + } } return $Entities; -- 2.39.5