From 77eb3abb56a5128403e142ff6146bd21da526d34 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Fri, 11 Feb 2022 16:48:11 +0100 Subject: [PATCH] wip #5089 @0.25 --- app/Jobs/SearchIndex.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/Jobs/SearchIndex.php b/app/Jobs/SearchIndex.php index 64007dc..83f7caf 100644 --- a/app/Jobs/SearchIndex.php +++ b/app/Jobs/SearchIndex.php @@ -77,7 +77,11 @@ class SearchIndex extends Index /** @var Asset[] $pdfs */ $pdfs = Asset::getPDFInResources(); foreach ($pdfs as $pdf) { - $document = new PDF($pdf->getFirstMediaInField('file_upload')->getPath()); + $file = $pdf->getFirstMediaInField('file_upload'); + if ($file == null) { + throw new \Exception('Aucun fichier dans l\'asset ' . $pdf->id); + } + $document = new PDF($file->getPath()); $document->setId($pdf->id); $document->setUrl($this->relativeURL($pdf->getFirstMediaUrl($pdf->file_upload))); $document->setTitle($pdf->title); @@ -88,7 +92,8 @@ class SearchIndex extends Index } } - public function relativeURL($URL) { + public function relativeURL($URL) + { // Get the relative URL by taking from /storage/ onwards // We assume that assets are always going to be in the storage folder return '.' . strstr($URL, '/storage/'); -- 2.39.5