Skip to content

[Cache] ProxyAdapter & TagAwareAdapter don't work together #30400

@dmaicher

Description

@dmaicher

Symfony version(s) affected: 3.4 until master

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 😊

https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php#L54

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy