Skip to content

Commit cbc268a

Browse files
Merge pull request #339 from daniellienert/bugfix/failed-asset-extract
BUGFIX: Do not blindly use array keys
2 parents 29b2e65 + 185d2e2 commit cbc268a

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

Classes/AssetExtraction/IngestAttachmentAssetExtractor.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,11 @@ public function extract(AssetInterface $asset): AssetContent
7575
$result = $this->elasticsearchClient->request('POST', '_ingest/pipeline/_simulate', [], json_encode($request))->getTreatedContent();
7676
$extractedAsset = Arrays::getValueByPath($result, 'docs.0.doc._source.attachment');
7777

78-
$this->logger->debug(sprintf('Extracted asset %s of type %s. Extracted %s characters of content', $asset->getResource()->getFilename(), $extractedAsset['content_type'], $extractedAsset['content_length']), LogEnvironment::fromMethodName(__METHOD__));
78+
if (!is_array($extractedAsset)) {
79+
$this->logger->error(sprintf('Error while extracting fulltext data from file "%s". See Elasticsearch error log line fo details.', $asset->getResource()->getFilename()), LogEnvironment::fromMethodName(__METHOD__));
80+
} else {
81+
$this->logger->debug(sprintf('Extracted asset %s of type %s. Extracted %s characters of content', $asset->getResource()->getFilename(), $extractedAsset['content_type'] ?? '-no-content-type-', $extractedAsset['content_length'] ?? '0'), LogEnvironment::fromMethodName(__METHOD__));
82+
}
7983

8084
return new AssetContent(
8185
$extractedAsset['content'] ?? '',
@@ -85,7 +89,7 @@ public function extract(AssetInterface $asset): AssetContent
8589
$extractedAsset['keywords'] ?? '',
8690
$extractedAsset['date'] ?? '',
8791
$extractedAsset['content_type'] ?? '',
88-
$extractedAsset['content_length'] ?? '',
92+
$extractedAsset['content_length'] ?? 0,
8993
$extractedAsset['language'] ?? ''
9094
);
9195
}

0 commit comments

Comments
 (0)