Skip to content

Commit

Permalink
Merge pull request #1127 from oat-sa/feat/ADF-1683/fix-case-stream-al…
Browse files Browse the repository at this point in the history
…ready-closed

fix: only close stream in case the resource is valid
  • Loading branch information
gabrielfs7 authored Jun 27, 2024
2 parents 22ca209 + 17f39eb commit 3728af2
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion common/oatbox/task/AbstractTaskAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,17 @@ protected function saveFile($path, $name)

$stream = fopen($path, 'r+');
$filesystem->writeStream($filename, $stream);
fclose($stream);

if (is_resource($stream)) {
fclose($stream);
} else {
$this->logWarning(
sprintf(
'Stream for file "%s" is not valid. It may be already closed',
$name
)
);
}

$file = $dir->getFile($filename);
return $this->getFileReferenceSerializer()->serialize($file);
Expand Down

0 comments on commit 3728af2

Please sign in to comment.