-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Mitigate dependency upon ConfigCache #7753
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
Mitigate dependency upon ConfigCache #7753
Conversation
Travis exited with a segfault on PHP 5.3.3 only...?!? |
Thanks for working on smaller PRs. That's much appreciated, and it definitely makes things easier. Unfortunately, this one cannot be merged as it would introduce a hard dependency between HttpKernel and Config for instance, which we must avoid as some projects using Symfony do not want to depend on Config (like Drupal for instance). As a rule of thumb, code duplication in Symfony exists for a reason, so refactoring like this one will almost always be rejected. |
I was aware of that need of f. e. Drupal, but somehow failed to see the new dep here. Sorry. Better now? |
What about moving |
The only client of these methods was removed in 669898b.
Regarding the Filesystem component: Good idea and better place, but would be a change dependency-wise? Component/Config then would need Component/Filesystem. Bundle/FrameworkBundle/* probably don't care... |
Adding the Filesystem component as a dep to Config is not a problem. |
For the method name in Filesystem, we should probably come up with a better name than |
Great, yes, will do. |
Clients of ConfigCache are/were using 0666 & ~umask().
} | ||
|
||
$this->rename($tmpFile, $filename); | ||
$this->chmod($filename, $mode); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is how it was before, but wouldn't it be better to chmod() first before moving the file in place?
Except for the getMetaFile method, everything else looks good to me. Can you also add a note in the Filesystem CHANGELOG? |
Adding the getMetaFile() was a reflex action as the meta file name is built in two different methods, though I forgot one of the places when picking from #7230. Shall I make it private? |
Just to be sure, don't we have to do anything about the new Config -> Filesystem dep? Add it to the Config component composer.json maybe? |
You are right, you need to add the filesystem component as a required dep for the config component. |
Nervermind, I'm doing to do it after the merge. |
Thanks, learned a lot already today. The next picks will probably become much more interesting than that :-) |
This PR was merged into the master branch. Discussion ---------- [Filesystem] Added a missing test case for Filesystem::dumpFile() This PR adds a test case for the ``Filesystem::dumpFile()`` method (introduced in #7753). | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | [](https://travis-ci.org/jakzal/symfony) | Fixed tickets | - | License | MIT | Doc PR | - Commits ------- 8fcf4c2 [Filesystem] Added a missing test case for Filesystem::dumpFile().
This PR was merged into the master branch. Discussion ---------- [Filesystem] Made sure Filesystem::dumpFile() overwrites an existing file #7753 introduced a change in behaviour. Before, ConfigCache simply used the ``rename()`` function to save a file. It was replaced by ``Filesystem::dumpFile()`` which internally uses ``Filesystem::rename()``. The later checks if file already exists and throws an exception if it exists. This PR makes sure that ``Filesystem::dumpFile()`` removes the file before creating a new one. Alternatively, we could introduce a third parameter to the ``Filesystem::rename()`` which would allow to overwrite the target file. Before #7752: * [CompilerDebugDumpPass](https://github.com/symfony/symfony/blob/d100ffaf761b46acdb2440c04602378b87b0d610/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/CompilerDebugDumpPass.php#L23) uses ConfigCache * [ConfigCache](https://github.com/symfony/symfony/blob/d100ffaf761b46acdb2440c04602378b87b0d610/src/Symfony/Component/Config/ConfigCache.php#L103) uses the [rename()](http://uk1.php.net/rename) function (which overwrites a file if it exists) After #7752: * [CompilerDebugDumpPass](https://github.com/symfony/symfony/blob/ad47bc47380188041b7889f40e380ad3766a0110/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/CompilerDebugDumpPass.php#L23) uses the ``Filesystem::dumpFile()`` * [Filesystem::dumpFile()](https://github.com/webfactory/symfony/blob/ad47bc47380188041b7889f40e380ad3766a0110/src/Symfony/Component/Filesystem/Filesystem.php#L458) uses the [Filesystem::rename()](https://github.com/webfactory/symfony/blob/ad47bc47380188041b7889f40e380ad3766a0110/src/Symfony/Component/Filesystem/Filesystem.php#L239) (which throws an exception if file exists) | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #7816 | License | MIT | Doc PR | ~ Commits ------- 4f4ec76 [Filesystem] Made sure Filesystem::dumpFile() overwrites an existing file.
2.3.0 | ||
----- | ||
|
||
* added the dumpFile() method to atomically write files |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo automatically
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, thats "atomically" (sic) - writing the file in a way that other user see either the old or the new one, but never a partially-written state.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, thanks! I've learned a new word :)
Could you please review symfony/symfony-docs#2592 , after your comment I'm not sure if it's correct.
Some clients use ConfigCache only for its ability to atomically write into a file.
The PR moves that code into the Filesystem component.
It's a pick off #7230.
To-Do: