Catch exception when trying to determine the creation_date

This commit is contained in:
Deon George 2024-09-29 18:07:38 +10:00
parent 4e39d01876
commit 7eb0379996

View File

@ -8,7 +8,6 @@ use Illuminate\Support\Traits\ForwardsCalls;
use Imagick; use Imagick;
use App\Casts\PostgresBytea; use App\Casts\PostgresBytea;
use App\Jobs\CatalogMove;
class Photo extends Abstracted\Catalog 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') && $this->Imagick_getImageProperty('exif:DateTime') === '0000:00:00 00:00:00')
return NULL; return NULL;
$result = Carbon::create($x= try {
($this->Imagick_getImageProperty('exif:DateTimeOriginal') && ($this->Imagick_getImageProperty('exif:DateTimeOriginal') !== '0000:00:00 00:00:00')) $result = Carbon::create(
? $this->Imagick_getImageProperty('exif:DateTimeOriginal').$this->Imagick_getImageProperty('exif:OffsetTimeOriginal') ($this->Imagick_getImageProperty('exif:DateTimeOriginal') && ($this->Imagick_getImageProperty('exif:DateTimeOriginal') !== '0000:00:00 00:00:00'))
: $this->Imagick_getImageProperty('exif:DateTime').$this->Imagick_getImageProperty('exif:OffsetTime')); ? $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; return $result ?: NULL;