You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description
When wrapping an adapter inside a ProxyAdapter its impossible to use it within a TagAwareAdapter.
How to reproduce
$cache = new \Symfony\Component\Cache\Adapter\TagAwareAdapter(
new \Symfony\Component\Cache\Adapter\ProxyAdapter(
new \Symfony\Component\Cache\Adapter\ArrayAdapter()
)
);
$item = $cache->getItem('foo');
$item->tag(['tag1', 'tag2']);
$item->set(true);
$cache->save($item);
var_dump($cache->getItem('foo')->get());
==>
array(2) {
["tag1"]=>
int(0)
["tag2"]=>
int(0)
}
So the actual value of the cache item is replaced by its tags.
@nicolas-grekas I tried to have a look and it seems to be related with the mysterious $innerItem of a CacheItem. If you could shed some light on this $innerItem and why it exists I might understand the logic and can fix it somehow 😊
Wow, I tried your code and you're right. Leaving the ProxyAdapter out resolves the problem.
It also does not help to supply a second Adapter for the tags pool
…icher)
This PR was merged into the 3.4 branch.
Discussion
----------
[Cache] fix using ProxyAdapter inside TagAwareAdapter
| Q | A
| ------------- | ---
| Branch? | 3.4
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #30400
| License | MIT
| Doc PR | -
EUFOSSA
After some debugging this is my first attempt to fix this issue @nicolas-grekas 😊 Let's discuss it.
without the fix the test fails like this:
```
Testing Symfony\Component\Cache\Tests\Adapter\TagAwareAndProxyAdapterIntegrationTest
F 1 / 1 (100%)
Time: 28 ms, Memory: 4.00MB
There was 1 failure:
1) Symfony\Component\Cache\Tests\Adapter\TagAwareAndProxyAdapterIntegrationTest::testIntegration
Failed asserting that Array &0 (
'tag1' => 0
'tag2' => 0
) is identical to 'bar'.
/var/www/symfony/src/Symfony/Component/Cache/Tests/Adapter/TagAwareAndProxyAdapterIntegrationTest.php:26
FAILURES!
Tests: 1, Assertions: 1, Failures: 1.
Commits
-------
98b9be9 [Cache] fix using ProxyAdapter inside TagAwareAdapter
Symfony version(s) affected: 3.4 until master
Description
When wrapping an adapter inside a
ProxyAdapter
its impossible to use it within aTagAwareAdapter
.How to reproduce
==>
So the actual value of the cache item is replaced by its tags.
@nicolas-grekas I tried to have a look and it seems to be related with the mysterious
$innerItem
of aCacheItem
. If you could shed some light on this$innerItem
and why it exists I might understand the logic and can fix it somehow 😊https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php#L54
The text was updated successfully, but these errors were encountered: