Skip to content

Commit

Permalink
[Cache] fix using ProxyAdapter inside TagAwareAdapter
Browse files Browse the repository at this point in the history
  • Loading branch information
dmaicher committed Apr 6, 2019
1 parent c8d6dec commit 7cb1dd7
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Symfony/Component/Cache/Adapter/ProxyAdapter.php
Expand Up @@ -156,7 +156,7 @@ private function doSave(CacheItemInterface $item, $method)
if (null === $expiry && 0 < $item["\0*\0defaultLifetime"]) {
$expiry = time() + $item["\0*\0defaultLifetime"];
}
$innerItem = $item["\0*\0poolHash"] === $this->poolHash ? $item["\0*\0innerItem"] : $this->pool->getItem($this->namespace.$item["\0*\0key"]);
$innerItem = $item["\0*\0poolHash"] === $this->poolHash && $item["\0*\0innerItem"] ? $item["\0*\0innerItem"] : $this->pool->getItem($this->namespace.$item["\0*\0key"]);
$innerItem->set($item["\0*\0value"]);
$innerItem->expiresAt(null !== $expiry ? \DateTime::createFromFormat('U', $expiry) : null);

Expand Down
1 change: 0 additions & 1 deletion src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php
Expand Up @@ -48,7 +48,6 @@ function ($key, $value, CacheItem $protoItem) {
$item->value = $value;
$item->defaultLifetime = $protoItem->defaultLifetime;
$item->expiry = $protoItem->expiry;
$item->innerItem = $protoItem->innerItem;
$item->poolHash = $protoItem->poolHash;

return $item;
Expand Down
@@ -0,0 +1,27 @@
<?php

namespace Symfony\Component\Cache\Tests\Adapter;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Cache\Adapter\ArrayAdapter;
use Symfony\Component\Cache\Adapter\ProxyAdapter;
use Symfony\Component\Cache\Adapter\TagAwareAdapter;

class TagAwareAndProxyAdapterIntegrationTest extends TestCase
{
public function testIntegration(): void
{
$cache = new TagAwareAdapter(
new ProxyAdapter(
new ArrayAdapter()
)
);

$item = $cache->getItem('foo');
$item->tag(['tag1', 'tag2']);
$item->set('bar');
$cache->save($item);

$this->assertSame('bar', $cache->getItem('foo')->get());
}
}

0 comments on commit 7cb1dd7

Please sign in to comment.