From 1daf6f01f4d776464f3a53a1029b22ca52f0ccda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Thu, 27 Mar 2025 21:40:51 +0100 Subject: [PATCH] Fixed error 500 if internal attachment path was not resolvable to an URL This fixes issue #898 --- src/Services/EntityURLGenerator.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Services/EntityURLGenerator.php b/src/Services/EntityURLGenerator.php index c66b5fd9..78db06f0 100644 --- a/src/Services/EntityURLGenerator.php +++ b/src/Services/EntityURLGenerator.php @@ -156,8 +156,10 @@ class EntityURLGenerator public function viewURL(Attachment $entity): string { - if ($entity->hasInternal()) { - return $this->attachmentURLGenerator->getInternalViewURL($entity); + //If the underlying file path is invalid, null gets returned, which is not allowed here. + //We still have the chance to use an external path, if it is set. + if ($entity->hasInternal() && ($url = $this->attachmentURLGenerator->getInternalViewURL($entity)) !== null) { + return $url; } if($entity->hasExternal()) {