Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f68a8df

Browse filesBrowse 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
Copy full SHA for f68a8df

File tree

1 file changed

+1
-1
lines changed
Filter options

1 file changed

+1
-1
lines changed

‎src/Symfony/Component/Filesystem/Filesystem.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Filesystem/Filesystem.php
+1-1Lines changed: 1 addition & 1 deletion
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.