-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Filesystem] dumpFile not compatible with streams #10018
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I've just hit this myself, I'm guessing there's no simple solution? |
Just ran into this issue. Curious what people are doing to work around it? avoiding dumpFile? |
@ericduran You can use |
@pablodip Yea, I just overwrote dumpFile in my own Filesystem class and switch to using Thanks. |
@ericduran the issue is that file_put_contents is not atomic (it can write part of the content and then fail) |
@stof yep :) I get the issue, I guess the real question is do I prefer having test coverage with something that is not atomic or no test coverage with something that is atomic :-/ I went with the test coverage over reliability ha, kinda ironic. |
PR #14970 has been closed because it was not finished and the original author does not have time to finish the work. Anyone can take over the work of course. |
…ams (markchalloner, pierredup) This PR was merged into the 2.8 branch. Discussion ---------- [Filesystem] Changed dumpFile to allow dumping to streams | Q | A | ------------- | --- | Bug fix? | yes | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #10018 | License | MIT | Doc PR | symfony/symfony-docs#5393 This is a follow-up of #14970 with comments addressed Commits ------- 5ca7dee Fix mode a17aa5e Fixed failing test for HHVM 61a3afd Removed unused logic in MockStream 247266c Update coding standard for MockStream c6a7747 [Filesystem] added tempnam() stream wrapper aware version of PHP's native tempnam() and fixed dumpFile to allow dumping to streams
This is because it creates a normal file with
tempnam
and then renames it, but renaming between different streams is not possible:https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Filesystem/Filesystem.php#L457
I discovered this when trying to use a virtual file system (https://github.com/mikey179/vfsStream) for tests, trying to pass it as the kernel root dir, but not being able because the kernel uses the
ConfigCache
, and this last the filesystemdumpFile
:https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Config/ConfigCache.php#L98
The text was updated successfully, but these errors were encountered: