diff --git a/classes/announcement/Repository.php b/classes/announcement/Repository.php index c3b31a82a6c..021e0f58151 100644 --- a/classes/announcement/Repository.php +++ b/classes/announcement/Repository.php @@ -165,7 +165,7 @@ public function edit(Announcement $announcement, array $params) $this->dao->update($newAnnouncement); $image = $newAnnouncement->getImage(); - $hasNewImage = $image && $image['temporaryFileId']; + $hasNewImage = $image['temporaryFileId'] ?? null; if ((!$image || $hasNewImage) && $announcement->getImage()) { $this->deleteImage($announcement); @@ -227,7 +227,7 @@ public function getFileUploadBaseUrl(?Context $context = null): string protected function handleImageUpload(Announcement $announcement): void { $image = $announcement->getImage(); - if ($image && $image['temporaryFileId']) { + if ($image['temporaryFileId'] ?? null) { $user = Application::get()->getRequest()->getUser(); $image = $announcement->getImage(); $temporaryFileManager = new TemporaryFileManager(); @@ -315,7 +315,7 @@ protected function getImageFilename(Announcement $announcement, TemporaryFile $t protected function deleteImage(Announcement $announcement): void { $image = $announcement->getImage(); - if ($image && $image['uploadName']) { + if ($image['uploadName'] ?? null) { $publicFileManager = new PublicFileManager(); $filesPath = $announcement->getAssocId() ? $publicFileManager->getContextFilesPath($announcement->getAssocId()) diff --git a/classes/highlight/Repository.php b/classes/highlight/Repository.php index 225cf67bfeb..52c4cf0cffc 100644 --- a/classes/highlight/Repository.php +++ b/classes/highlight/Repository.php @@ -188,7 +188,7 @@ public function edit(Highlight $highlight, array $params): void $this->dao->update($newHighlight); $image = $newHighlight->getImage(); - $hasNewImage = $image && $image['temporaryFileId']; + $hasNewImage = $image['temporaryFileId'] ?? null; if ((!$image || $hasNewImage) && $highlight->getImage()) { $this->deleteImage($highlight); @@ -263,7 +263,7 @@ public function getFileUploadBaseUrl(?Context $context = null): string protected function handleImageUpload(Highlight $highlight): void { $image = $highlight->getImage(); - if ($image && $image['temporaryFileId']) { + if ($image['temporaryFileId'] ?? null) { $user = Application::get()->getRequest()->getUser(); $image = $highlight->getImage(); $temporaryFileManager = new TemporaryFileManager(); @@ -347,7 +347,7 @@ protected function getImageFilename(Highlight $highlight, TemporaryFile $tempora protected function deleteImage(Highlight $highlight): void { $image = $highlight->getImage(); - if ($image && $image['uploadName']) { + if ($image['uploadName'] ?? null) { $publicFileManager = new PublicFileManager(); $filesPath = $highlight->getContextId() ? $publicFileManager->getContextFilesPath($highlight->getContextId())