Skip to content

Commit f76f92f

Browse files
committed
Prevent type error on getCacheEntryIdentifier()
1 parent 50a5503 commit f76f92f

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

Classes/Channel/EmailChannel.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*/
88

99
use Neos\Flow\Annotations as Flow;
10+
use Neos\Flow\ResourceManagement\Exception as ResourceException;
1011
use Neos\Flow\ResourceManagement\PersistentResource;
1112
use Neos\Flow\ResourceManagement\ResourceManager;
1213
use Neos\SwiftMailer\Message;
@@ -157,12 +158,13 @@ private function embedPlainResourceCallback(array $matches): string
157158
return $plain;
158159
}
159160

160-
/**
161-
* @param PersistentResource $resource
162-
* @return Swift_Attachment
163-
*/
164-
public function createSwiftAttachmentFromPersistentResource(PersistentResource $resource): Swift_Attachment
161+
public function createSwiftAttachmentFromPersistentResource(PersistentResource $resource): ?Swift_Attachment
165162
{
163+
if (!is_string($resource->getSha1())) {
164+
// Throw exception to prevent type error on getCacheEntryIdentifier(): "Return value must be of type string, null returned"
165+
throw new ResourceException('No sha1 set in persistent resource', 1733826832);
166+
}
167+
166168
// No exception handling here. This provides flexibility to handle it outside or by aspects
167169
$path = $resource->createTemporaryLocalCopy();
168170
$attachment = Swift_Attachment::fromPath($path, $resource->getMediaType());

0 commit comments

Comments
 (0)