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
SimpleCacheAdapter fails to cache any item if a namespace is used #32025
Merged
fabpot
merged 1 commit into
symfony:3.4
from
moufmouf:broken_simplecacheadapter_with_namespace
Jun 14, 2019
Merged
SimpleCacheAdapter fails to cache any item if a namespace is used #32025
fabpot
merged 1 commit into
symfony:3.4
from
moufmouf:broken_simplecacheadapter_with_namespace
Jun 14, 2019
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
src/Symfony/Component/Cache/Tests/Adapter/SimpleCacheAdapterTest.php
Outdated
Show resolved
Hide resolved
moufmouf
force-pushed
the
broken_simplecacheadapter_with_namespace
branch
4 times, most recently
from
June 13, 2019 14:17
ca39d00
to
b50221c
Compare
@nicolas-grekas Ready for review. I think I took into account all your comments. What do you want me to do with #32019? Shall I close it (if you want to backport the bug from this version?) or shall I continue working on it to make it in line with this PR? |
nicolas-grekas
approved these changes
Jun 13, 2019
fabpot
approved these changes
Jun 14, 2019
Thank you @moufmouf. |
fabpot
force-pushed
the
broken_simplecacheadapter_with_namespace
branch
from
June 14, 2019 11:16
9f8be54
to
ffd3469
Compare
fabpot
added a commit
that referenced
this pull request
Jun 14, 2019
…is used (moufmouf) This PR was squashed before being merged into the 3.4 branch (closes #32025). Discussion ---------- SimpleCacheAdapter fails to cache any item if a namespace is used | Q | A | ------------- | --- | Branch? |3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | License | MIT This is a backport of #32019 The SimpleCacheAdapter extends AdapterTestCase. When adding a namespace, the AdapterTestCase adds ":" after the namespace: https://github.com/symfony/symfony/blob/v4.3.1/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php#L37 The namespace is prepended to the cache key. But in PSR-16, the ":" is a forbidden character. As a result, the cache key is invalid and cache is not persisted. If you use Psr16Adapter + a namespace, the cache simply does not work. As per @nicolas-grekas advices, a NS_SEPARATOR const is added to change the namespace separator for the `SimpleCacheAdapter` to "_" (that is compatible with PSR-16). The first commit of this PR starts with an additional test and no fix (to showcase the problem). Commits ------- ffd3469 SimpleCacheAdapter fails to cache any item if a namespace is used
This was referenced Jun 26, 2019
Merged
Merged
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a backport of #32019
The SimpleCacheAdapter extends AdapterTestCase.
When adding a namespace, the AdapterTestCase adds ":" after the namespace:
https://github.com/symfony/symfony/blob/v4.3.1/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php#L37
The namespace is prepended to the cache key.
But in PSR-16, the ":" is a forbidden character.
As a result, the cache key is invalid and cache is not persisted. If you use Psr16Adapter + a namespace, the cache simply does not work.
As per @nicolas-grekas advices, a NS_SEPARATOR const is added to change the namespace separator for the
SimpleCacheAdapter
to "_" (that is compatible with PSR-16).The first commit of this PR starts with an additional test and no fix (to showcase the problem).