Skip to content

Commit 8d6c790

Browse files
Merge pull request #369 from Flowpack/bugfix/dont-fail-when-stream-fails
BUGFIX: Do not fail when the resource stream cannot be retrieved
2 parents 8a54c40 + 8c1b05b commit 8d6c790

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

Classes/AssetExtraction/IngestAttachmentAssetExtractor.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class IngestAttachmentAssetExtractor implements AssetExtractorInterface
5151
public function extract(AssetInterface $asset): AssetContent
5252
{
5353
$extractedAsset = null;
54-
54+
5555
$request = [
5656
'pipeline' => [
5757
'description' => 'Attachment Extraction',
@@ -101,13 +101,19 @@ public function extract(AssetInterface $asset): AssetContent
101101

102102
/**
103103
* @param AssetInterface $asset
104-
* @return null|string
104+
* @return string
105105
*/
106-
protected function getAssetContent(AssetInterface $asset): ?string
106+
protected function getAssetContent(AssetInterface $asset): string
107107
{
108108
$stream = $asset->getResource()->getStream();
109+
110+
if ($stream === false) {
111+
$this->logger->error(sprintf('Could not get the file stream of resource with sah1 %s of asset %s.', $asset->getResource()->getSha1(), $asset->getTitle()), LogEnvironment::fromMethodName(__METHOD__));
112+
return '';
113+
}
114+
109115
stream_filter_append($stream, 'convert.base64-encode');
110116
$result = stream_get_contents($stream);
111-
return $result !== false ? $result : null;
117+
return $result !== false ? $result : '';
112118
}
113119
}

0 commit comments

Comments
 (0)