Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
Psr16Adapter fails to cache any item if a namespace is used#32019
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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
635206e to500fba8Compareb8158ea to02fd552Comparenicolas-grekas commentedJun 13, 2019
Wow, thanks for spotting. The bug exists on 3.4, in |
stof commentedJun 13, 2019
Why would we need to use different separators per implementation, rather than using a separator accepted by all ? |
nicolas-grekas commentedJun 13, 2019
Two reasons, on a very different scale:
|
moufmouf commentedJun 13, 2019
Ok, opened a new PR#32025 that targets Symfony 3.4. Shall I close this one or continue working on it too? |
nicolas-grekas commentedJun 13, 2019
Nope, no need, thanks. |
…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 | MITThis is a backport of#32019The 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#L37The 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
The Psr16Adapter 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.
The first commit of this PR starts with an additional test and no fix (to showcase the problem).