Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
mpdude wants to merge9 commits intosymfony:masterfromwebfactory:issue-7230/picks/cache-file-utils
Closed

Mitigate dependency upon ConfigCache#7753

mpdude wants to merge9 commits intosymfony:masterfromwebfactory:issue-7230/picks/cache-file-utils

Conversation

mpdude
Copy link
Contributor

QA
Bug fix?no
New feature?yes (refactoring)
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets
LicenseMIT
Doc PRtodo, issue issymfony/symfony-docs#2531

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:

  • Update docs for the Filesystem component

@mpdude
Copy link
ContributorAuthor

Travis exited with a segfault on PHP 5.3.3 only...?!?

@jakzal
Copy link
Contributor

@mpdude yes, it's not your fault though. The problem exist for some time now (see#7754).

@fabpot
Copy link
Member

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.

@mpdude
Copy link
ContributorAuthor

I was aware of that need of f. e. Drupal, but somehow failed to see the new dep here. Sorry.

Better now?

@fabpot
Copy link
Member

What about movingCacheFileUtils::dumpInFile() to the Filsystem component class instead? And remove the other two methods that are not used anyway.

The only client of these methods was removed in669898b.
@mpdude
Copy link
ContributorAuthor

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

@fabpot
Copy link
Member

Adding the Filesystem component as a dep to Config is not a problem.

@fabpot
Copy link
Member

For the method name in Filesystem, we should probably come up with a better name thandumpInFile.dumpFile orstoreFile should be enough, no?

@mpdude
Copy link
ContributorAuthor

Great, yes, will do.

}

$this->rename($tmpFile, $filename);
$this->chmod($filename, $mode);
Copy link
ContributorAuthor

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?

@fabpot
Copy link
Member

Except for the getMetaFile method, everything else looks good to me. Can you also add a note in the Filesystem CHANGELOG?

@mpdude
Copy link
ContributorAuthor

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?

@mpdude
Copy link
ContributorAuthor

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?

@fabpot
Copy link
Member

You are right, you need to add the filesystem component as a required dep for the config component.

@fabpot
Copy link
Member

Nervermind, I'm doing to do it after the merge.

@mpdude
Copy link
ContributorAuthor

Thanks, learned a lot already today.

The next picks will probably become much more interesting than that :-)

fabpot added a commit that referenced this pull requestApr 22, 2013
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?   | [![Build Status](https://travis-ci.org/jakzal/symfony.png?branch=dumpfile-tests)](https://travis-ci.org/jakzal/symfony)| Fixed tickets | -| License       | MIT| Doc PR        | -Commits-------8fcf4c2 [Filesystem] Added a missing test case for Filesystem::dumpFile().
fabpot added a commit that referenced this pull requestApr 24, 2013
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

typoautomatically

Copy link
ContributorAuthor

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.

Copy link
Member

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 reviewsymfony/symfony-docs#2592 , after your comment I'm not sure if it's correct.

@mpdudempdude deleted the issue-7230/picks/cache-file-utils branchSeptember 24, 2015 19:25
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

4 participants
@mpdude@jakzal@fabpot@wouterj

[8]ページ先頭

©2009-2025 Movatter.jp