Skip to content

Commit f68a8df

Browse files
bug #54878 [Filesystem] Fix dumpFile stat failed error hitting custom handler (acoulton)
This PR was merged into the 5.4 branch. Discussion ---------- [Filesystem] Fix dumpFile `stat failed` error hitting custom handler | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | See below | License | MIT Since #54471, dumpFile will trigger a `fileperms(): stat failed` error when writing to a filename that does not yet exist. This was silenced from PHP's default handler with the `@` operator. However, the error is still passed to any custom handler that the application has registered, and can therefore cause exceptions or spurious logging depending on the implementation of the handler. The better solution, which is consistent with all other calls to native functions in this class, would be to use `self::box` to catch and ignore the potential error so that it never leaks outside this class. Commits ------- 247182a [Filesystem] Fix dumpFile `stat failed` error hitting custom handler
2 parents a8a31e6 + 247182a commit f68a8df

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Symfony/Component/Filesystem/Filesystem.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ public function dumpFile(string $filename, $content)
691691
throw new IOException(sprintf('Failed to write file "%s": ', $filename).self::$lastError, 0, null, $filename);
692692
}
693693

694-
self::box('chmod', $tmpFile, @fileperms($filename) ?: 0666 & ~umask());
694+
self::box('chmod', $tmpFile, self::box('fileperms', $filename) ?: 0666 & ~umask());
695695

696696
$this->rename($tmpFile, $filename, true);
697697
} finally {

0 commit comments

Comments
 (0)