Skip to content

[DependencyInjection] Minor - add note that file_put_contents is non-atomic #15511

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

Merged
merged 1 commit into from
Aug 8, 2022

Conversation

trakos
Copy link
Contributor

@trakos trakos commented Jul 13, 2021

I have minor gripe with article at https://symfony.com/doc/current/components/dependency_injection/compilation.html#dumping-the-configuration-for-performance

While the final snippet is fine, there are some examples along the way that suggest using file_put_contents to write cached container, without using LOCK_EX. I think that could produce some issues in production environment. With multiple concurrent requests, one might partially write the file, while other could try to require it before it is ready.

Maybe it's worth adding a note as suggested in this MR, to make readers aware of this fact?

@javiereguiluz
Copy link
Member

Thanks Piotr! I liked this contribution. We reworded it a bit while merging, but we kept most of your original contents. Sorry it took us so long to merge it.

@trakos trakos deleted the patch-1 branch August 8, 2022 21:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants