Skip to content

Commit 17c7150

Browse files
bug #62614 [Cache] Fix NullAdapter must set taggable (a.dmitryuk)
This PR was squashed before being merged into the 7.4 branch. Discussion ---------- [Cache] Fix NullAdapter must set taggable | Q | A | ------------- | --- | Branch? | 7.4 | Bug fix? | yes | New feature? | no <!-- if yes, also update src/**/CHANGELOG.md --> | Deprecations? | no <!-- if yes, also update UPGRADE-*.md and src/**/CHANGELOG.md --> | Issues | Fix #... <!-- prefix each issue number with "Fix #"; no need to create an issue if none exists, explain below --> | License | MIT After PR #61127 merged NullAdapter still doesn't work as taggable. After tagging there is an error ``` Cache item "tag1" comes from a non tag-aware pool: you cannot tag it. ``` Psalm must fail here same as https://github.com/symfony/symfony/blob/8.1/src/Symfony/Component/Cache/Adapter/AbstractTagAwareAdapter.php#L69 <img width="1896" height="137" alt="image" src="https://github.com/user-attachments/assets/33fb59d4-b048-495d-950c-005dbbaa3ea0" /> Commits ------- 273f1b7 [Cache] Fix NullAdapter must set taggable
2 parents 78055a2 + 273f1b7 commit 17c7150

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/Symfony/Component/Cache/Adapter/NullAdapter.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public function __construct()
2828
self::$createCacheItem ??= \Closure::bind(
2929
static function ($key) {
3030
$item = new CacheItem();
31+
$item->isTaggable = true;
3132
$item->key = $key;
3233
$item->isHit = false;
3334

src/Symfony/Component/Cache/Tests/Adapter/NullAdapterTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,15 @@ public function testCommit()
138138
$this->assertTrue($this->createCachePool()->commit());
139139
}
140140

141+
public function testTaggable()
142+
{
143+
$this->expectNotToPerformAssertions();
144+
$adapter = $this->createCachePool();
145+
$item = $adapter->getItem('any_item');
146+
// No error triggered 'Cache item "%s" comes from a non tag-aware pool: you cannot tag it.'
147+
$item->tag(['tag1']);
148+
}
149+
141150
public function testInvalidateTags()
142151
{
143152
$adapter = $this->createCachePool();

0 commit comments

Comments
 (0)