Skip to content

Commit fd618c4

Browse files
authored
Merge pull request #3449 from kdambekalns/bugfix/avoid-type-error-on-publish
BUGFIX: Avoid type error during `publishFile()`
2 parents a2b8723 + 398f959 commit fd618c4

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

Neos.Flow/Classes/ResourceManagement/Target/FileSystemTarget.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -329,14 +329,18 @@ protected function publishFile($sourceStream, $relativeTargetPathAndFilename)
329329
}
330330

331331
try {
332-
$targetFileHandle = fopen($targetPathAndFilename, 'w');
333-
$result = stream_copy_to_stream($sourceStream, $targetFileHandle);
334-
fclose($targetFileHandle);
332+
$targetFileHandle = fopen($targetPathAndFilename, 'wb');
333+
if ($targetFileHandle === false) {
334+
$result = false;
335+
} else {
336+
$result = stream_copy_to_stream($sourceStream, $targetFileHandle);
337+
fclose($targetFileHandle);
338+
}
335339
} catch (\Exception $exception) {
336340
$result = false;
337341
}
338342
if ($result === false) {
339-
throw new TargetException(sprintf('Could not publish "%s" into resource publishing target "%s" because the source file could not be copied to the target location.', $sourceStream, $this->name), 1375258399, (isset($exception) ? $exception : null));
343+
throw new TargetException(sprintf('Could not publish "%s" into resource publishing target "%s" because the source file could not be copied to the target location "%s".', $sourceStream, $this->name, $targetPathAndFilename), 1375258399, ($exception ?? null));
340344
}
341345

342346
$this->logger->debug(sprintf('FileSystemTarget: Published file. (target: %s, file: %s)', $this->name, $relativeTargetPathAndFilename));

0 commit comments

Comments
 (0)