From 7eb0379996a4b6da28b246641d4d1adc61d7fe68 Mon Sep 17 00:00:00 2001 From: Deon George Date: Sun, 29 Sep 2024 18:07:38 +1000 Subject: [PATCH] Catch exception when trying to determine the creation_date --- app/Models/Photo.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/app/Models/Photo.php b/app/Models/Photo.php index f31ee38..acf13b2 100644 --- a/app/Models/Photo.php +++ b/app/Models/Photo.php @@ -8,7 +8,6 @@ use Illuminate\Support\Traits\ForwardsCalls; use Imagick; use App\Casts\PostgresBytea; -use App\Jobs\CatalogMove; class Photo extends Abstracted\Catalog { @@ -158,10 +157,17 @@ class Photo extends Abstracted\Catalog && $this->Imagick_getImageProperty('exif:DateTime') === '0000:00:00 00:00:00') return NULL; - $result = Carbon::create($x= - ($this->Imagick_getImageProperty('exif:DateTimeOriginal') && ($this->Imagick_getImageProperty('exif:DateTimeOriginal') !== '0000:00:00 00:00:00')) - ? $this->Imagick_getImageProperty('exif:DateTimeOriginal').$this->Imagick_getImageProperty('exif:OffsetTimeOriginal') - : $this->Imagick_getImageProperty('exif:DateTime').$this->Imagick_getImageProperty('exif:OffsetTime')); + try { + $result = Carbon::create( + ($this->Imagick_getImageProperty('exif:DateTimeOriginal') && ($this->Imagick_getImageProperty('exif:DateTimeOriginal') !== '0000:00:00 00:00:00')) + ? $this->Imagick_getImageProperty('exif:DateTimeOriginal').$this->Imagick_getImageProperty('exif:OffsetTimeOriginal') + : $this->Imagick_getImageProperty('exif:DateTime').$this->Imagick_getImageProperty('exif:OffsetTime')); + + } catch (\Exception $e) { + Log::alert(sprintf('We got exception [%s] when finding the create date',$e->getMessage())); + + return NULL; + } return $result ?: NULL;