Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions lib/Service/SubmissionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -380,9 +380,19 @@ function (array $carry, Answer $answer) use ($questionPerQuestionId, $gridRowsPe
* @param list<non-empty-list<array{columns?: list<mixed|string>, label?: string, url?: string}|mixed|null|string>> $data
*/
private function exportData(array $header, array $data, string $fileFormat, ?File $file = null): string {
if ($file && $file->getContent()) {
$content = null;
if ($file) {
try {
$content = $file->getContent();
} catch (\Exception $e) {
$this->logger->warning('Failed to read existing linked file content: {msg}', ['msg' => $e->getMessage()]);
}
}

// Ignore whitespace-only files (e.g. S3 single-space placeholder).
if ($content !== null && trim($content) !== '') {
$existentFile = $this->tempManager->getTemporaryFile($fileFormat);
file_put_contents($existentFile, $file->getContent());
file_put_contents($existentFile, $content);
$spreadsheet = IOFactory::load($existentFile);
} else {
$spreadsheet = new Spreadsheet();
Expand Down
Loading