From 02a6f248b5041d68bf6e18d3e254aa7a79039a78 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 17 Jun 2019 19:18:24 +0200 Subject: [PATCH] [Cache] fix versioning with SimpleCacheAdapter --- .../Component/Cache/Adapter/SimpleCacheAdapter.php | 2 ++ src/Symfony/Component/Cache/Traits/AbstractTrait.php | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Cache/Adapter/SimpleCacheAdapter.php b/src/Symfony/Component/Cache/Adapter/SimpleCacheAdapter.php index de4dd745cd..dc3a9cec2d 100644 --- a/src/Symfony/Component/Cache/Adapter/SimpleCacheAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/SimpleCacheAdapter.php @@ -78,6 +78,8 @@ class SimpleCacheAdapter extends AbstractAdapter implements PruneableInterface /** * @return string the namespace separator for cache keys + * + * @internal */ protected static function getNsSeparator() { diff --git a/src/Symfony/Component/Cache/Traits/AbstractTrait.php b/src/Symfony/Component/Cache/Traits/AbstractTrait.php index 83a86a5ee9..e225e07542 100644 --- a/src/Symfony/Component/Cache/Traits/AbstractTrait.php +++ b/src/Symfony/Component/Cache/Traits/AbstractTrait.php @@ -108,7 +108,7 @@ trait AbstractTrait if ($cleared = $this->versioningIsEnabled) { $namespaceVersion = substr_replace(base64_encode(pack('V', mt_rand())), static::getNsSeparator(), 5); try { - $cleared = $this->doSave(['@'.$this->namespace => $namespaceVersion], 0); + $cleared = $this->doSave([static::getNsSeparator().$this->namespace => $namespaceVersion], 0); } catch (\Exception $e) { $cleared = false; } @@ -237,12 +237,12 @@ trait AbstractTrait if ($this->versioningIsEnabled && '' === $this->namespaceVersion) { $this->namespaceVersion = '1'.static::getNsSeparator(); try { - foreach ($this->doFetch(['@'.$this->namespace]) as $v) { + foreach ($this->doFetch([static::getNsSeparator().$this->namespace]) as $v) { $this->namespaceVersion = $v; } if ('1'.static::getNsSeparator() === $this->namespaceVersion) { $this->namespaceVersion = substr_replace(base64_encode(pack('V', time())), static::getNsSeparator(), 5); - $this->doSave(['@'.$this->namespace => $this->namespaceVersion], 0); + $this->doSave([static::getNsSeparator().$this->namespace => $this->namespaceVersion], 0); } } catch (\Exception $e) { } @@ -268,6 +268,8 @@ trait AbstractTrait /** * @return string the namespace separator for cache keys + * + * @internal */ protected static function getNsSeparator() {