Skip to content

Commit 1daf6f0

Browse files
committed
Fixed error 500 if internal attachment path was not resolvable to an URL
This fixes issue #898
1 parent d3b2257 commit 1daf6f0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/Services/EntityURLGenerator.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,10 @@ public function timeTravelURL(AbstractDBElement $entity, \DateTimeInterface $dat
156156

157157
public function viewURL(Attachment $entity): string
158158
{
159-
if ($entity->hasInternal()) {
160-
return $this->attachmentURLGenerator->getInternalViewURL($entity);
159+
//If the underlying file path is invalid, null gets returned, which is not allowed here.
160+
//We still have the chance to use an external path, if it is set.
161+
if ($entity->hasInternal() && ($url = $this->attachmentURLGenerator->getInternalViewURL($entity)) !== null) {
162+
return $url;
161163
}
162164

163165
if($entity->hasExternal()) {

0 commit comments

Comments
 (0)