Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fd825c3

Browse filesBrowse files
committed
[Cache] fix using ProxyAdapter inside TagAwareAdapter
1 parent c8d6dec commit fd825c3
Copy full SHA for fd825c3

File tree

3 files changed

+29
-2
lines changed
Filter options

3 files changed

+29
-2
lines changed

‎src/Symfony/Component/Cache/Adapter/ProxyAdapter.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Cache/Adapter/ProxyAdapter.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ private function doSave(CacheItemInterface $item, $method)
156156
if (null === $expiry && 0 < $item["\0*\0defaultLifetime"]) {
157157
$expiry = time() + $item["\0*\0defaultLifetime"];
158158
}
159-
$innerItem = $item["\0*\0poolHash"] === $this->poolHash ? $item["\0*\0innerItem"] : $this->pool->getItem($this->namespace.$item["\0*\0key"]);
159+
$innerItem = $item["\0*\0poolHash"] === $this->poolHash && $item["\0*\0innerItem"] ? $item["\0*\0innerItem"] : $this->pool->getItem($this->namespace.$item["\0*\0key"]);
160160
$innerItem->set($item["\0*\0value"]);
161161
$innerItem->expiresAt(null !== $expiry ? \DateTime::createFromFormat('U', $expiry) : null);
162162

‎src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ function ($key, $value, CacheItem $protoItem) {
4848
$item->value = $value;
4949
$item->defaultLifetime = $protoItem->defaultLifetime;
5050
$item->expiry = $protoItem->expiry;
51-
$item->innerItem = $protoItem->innerItem;
5251
$item->poolHash = $protoItem->poolHash;
5352

5453
return $item;
+28Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
namespace Symfony\Component\Cache\Tests\Adapter;
4+
5+
6+
use PHPUnit\Framework\TestCase;
7+
use Symfony\Component\Cache\Adapter\ArrayAdapter;
8+
use Symfony\Component\Cache\Adapter\ProxyAdapter;
9+
use Symfony\Component\Cache\Adapter\TagAwareAdapter;
10+
11+
class TagAwareAndProxyAdapterIntegrationTest extends TestCase
12+
{
13+
public function testIntegration(): void
14+
{
15+
$cache = new TagAwareAdapter(
16+
new ProxyAdapter(
17+
new ArrayAdapter()
18+
)
19+
);
20+
21+
$item = $cache->getItem('foo');
22+
$item->tag(['tag1', 'tag2']);
23+
$item->set('bar');
24+
$cache->save($item);
25+
26+
$this->assertSame('bar', $cache->getItem('foo')->get());
27+
}
28+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.