Fixed error 500 if internal attachment path was not resolvable to an URL

This fixes issue #898
This commit is contained in:
Jan Böhmer 2025-03-27 21:40:51 +01:00
parent d3b225771c
commit 1daf6f01f4

View file

@ -156,8 +156,10 @@ class EntityURLGenerator
public function viewURL(Attachment $entity): string public function viewURL(Attachment $entity): string
{ {
if ($entity->hasInternal()) { //If the underlying file path is invalid, null gets returned, which is not allowed here.
return $this->attachmentURLGenerator->getInternalViewURL($entity); //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()) { if($entity->hasExternal()) {