From e525fa10550f95e4ce41fdeed97e4c4711b40032 Mon Sep 17 00:00:00 2001 From: Alexandre Parent Date: Mon, 31 Aug 2020 10:08:37 -0400 Subject: [PATCH] [Cache] Psr16Cache does not handle Proxy cache items --- src/Symfony/Component/Cache/Psr16Cache.php | 1 + .../Cache/Tests/Psr16CacheProxyTest.php | 30 +++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 src/Symfony/Component/Cache/Tests/Psr16CacheProxyTest.php diff --git a/src/Symfony/Component/Cache/Psr16Cache.php b/src/Symfony/Component/Cache/Psr16Cache.php index 7358bf5184..ba8b5b37f9 100644 --- a/src/Symfony/Component/Cache/Psr16Cache.php +++ b/src/Symfony/Component/Cache/Psr16Cache.php @@ -44,6 +44,7 @@ class Psr16Cache implements CacheInterface, PruneableInterface, ResettableInterf $createCacheItem = \Closure::bind( static function ($key, $value, $allowInt = false) use (&$cacheItemPrototype) { $item = clone $cacheItemPrototype; + $item->poolHash = $item->innerItem = null; $item->key = $allowInt && \is_int($key) ? (string) $key : CacheItem::validateKey($key); $item->value = $value; $item->isHit = false; diff --git a/src/Symfony/Component/Cache/Tests/Psr16CacheProxyTest.php b/src/Symfony/Component/Cache/Tests/Psr16CacheProxyTest.php new file mode 100644 index 0000000000..f5347bf9bf --- /dev/null +++ b/src/Symfony/Component/Cache/Tests/Psr16CacheProxyTest.php @@ -0,0 +1,30 @@ +assertNull($cache->get('some-key')); + $this->assertTrue($cache->set('some-other-key', 'value')); + + $item = $pool->getItem('my-namespace.some-other-key', 'value'); + $this->assertTrue($item->isHit()); + $this->assertSame('value', $item->get()); + } +}