Skip to content

[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

Closed
pablodip opened this issue Jan 14, 2014 · 7 comments
Closed

[Filesystem] dumpFile not compatible with streams #10018

pablodip opened this issue Jan 14, 2014 · 7 comments

Comments

@pablodip
Copy link
Contributor

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 filesystem dumpFile:

https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Config/ConfigCache.php#L98

@andyvenus
Copy link

I've just hit this myself, I'm guessing there's no simple solution?

@ericduran
Copy link
Contributor

Just ran into this issue. Curious what people are doing to work around it? avoiding dumpFile?

@pablodip
Copy link
Contributor Author

@ericduran You can use dumpFile, but not with streams (at least for now).

@ericduran
Copy link
Contributor

@pablodip Yea, I just overwrote dumpFile in my own Filesystem class and switch to using file_put_contents() not ideal but at least I can test this for now with vfsStream.

Thanks.

@stof
Copy link
Member

stof commented Jan 3, 2015

@ericduran the issue is that file_put_contents is not atomic (it can write part of the content and then fail)

@ericduran
Copy link
Contributor

@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.

@fabpot
Copy link
Member

fabpot commented Oct 6, 2015

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.

@fabpot fabpot closed this as completed Nov 9, 2015
fabpot added a commit that referenced this issue Nov 9, 2015
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants