From 7cee5609f582c6ac4fc48faef10be82435d07136 Mon Sep 17 00:00:00 2001 From: Martin Kirilov Date: Mon, 5 Jun 2017 03:15:00 +0300 Subject: [PATCH] [Cache] MemcachedAdapter not working with TagAwareAdapter It seems that when MemcachedAdapter is used with TagAwareAdapter, it fails to fetch items, even though I thoroughly tested fetching items with the exact same keys under the same namespace. Turns out the issue lies in `const TAGS_PREFIX = "\0tags\0";` for unknown to me reasons. Hardcoding that to '__tags__' in my project did the trick and I've been using it for a couple of days now and it seems fine. The reason I had to completely copy/paste this file in my local project is self:: instead of static:: usage. I am not sure whether that is a mistake or is done on purpose, but in order to have this work for me I need to be able to override that constant. Going with static:: seems like a good solution to me, then I can set whatever prefix I need for the tags. --- src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php b/src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php index 1d9dc7ce57241..1e0617ebe271d 100644 --- a/src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php @@ -281,7 +281,7 @@ private function generateItems($items, array $tagKeys) foreach ($items as $key => $item) { if (!$tagKeys) { - yield $key => $f($item, self::TAGS_PREFIX.$key, $itemTags); + yield $key => $f($item, static::TAGS_PREFIX.$key, $itemTags); continue; } if (!isset($tagKeys[$key])) { @@ -306,7 +306,7 @@ private function generateItems($items, array $tagKeys) $tagVersions = $tagKeys = null; foreach ($bufferedItems as $key => $item) { - yield $key => $f($item, self::TAGS_PREFIX.$key, $itemTags); + yield $key => $f($item, static::TAGS_PREFIX.$key, $itemTags); } $bufferedItems = null; }