Skip to content

PSR16::getMultiple returns invalid value #58632

Open
@JoniJnm

Description

@JoniJnm

Symfony version(s) affected

7.1.2

Description

PSR16::getMultiple is not returning the expected value when the adapter is a TagAwareAdapter

Instead of the value, it's returning a instance of ValueWrapped

How to reproduce

$adapter = new TagAwareAdapter(new ArrayAdapter());
$cache = new Psr16Cache($adapter);
$cache->set('k', 'v');

// ok => v
$value = $cache->get('k');

// not ok, a ValueWrapped object (©)
// expected value: ['k' => 'v']
$value = $cache->getMultiple(['k']);

Possible Solution

I'm not sure what's the solution, but in the following code:

https://github.com/symfony/cache/blob/7.1/CacheItem.php#L165-L173

because it's a tagAware there is a key with empty "tags", and that's why it's returning a ValueWrapped

In https://github.com/symfony/cache/blob/7.1/Psr16Cache.php#L150, removing the ! it also works (so just returning $item->get())

Additional Context

No response

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