From b8158ea35e53f9e787f761e99a855d7641b3fdc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Thu, 13 Jun 2019 10:15:28 +0200 Subject: [PATCH] Changing namespace separator to _ to match PSR-16 allowed keys --- src/Symfony/Component/Cache/Adapter/AbstractAdapter.php | 2 +- .../Cache/Tests/Adapter/MaxIdLengthAdapterTest.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php b/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php index 883a94ba9bae8..6bfcb99ed2dcf 100644 --- a/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/AbstractAdapter.php @@ -34,7 +34,7 @@ abstract class AbstractAdapter implements AdapterInterface, CacheInterface, Logg protected function __construct(string $namespace = '', int $defaultLifetime = 0) { - $this->namespace = '' === $namespace ? '' : CacheItem::validateKey($namespace).':'; + $this->namespace = '' === $namespace ? '' : CacheItem::validateKey($namespace).'_'; if (null !== $this->maxIdLength && \strlen($namespace) > $this->maxIdLength - 24) { throw new InvalidArgumentException(sprintf('Namespace must be %d chars max, %d given ("%s")', $this->maxIdLength - 24, \strlen($namespace), $namespace)); } diff --git a/src/Symfony/Component/Cache/Tests/Adapter/MaxIdLengthAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/MaxIdLengthAdapterTest.php index fec985e6da994..f18437a29b495 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/MaxIdLengthAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/MaxIdLengthAdapterTest.php @@ -26,8 +26,8 @@ public function testLongKey() $cache->expects($this->exactly(2)) ->method('doHave') ->withConsecutive( - [$this->equalTo('----------:nWfzGiCgLczv3SSUzXL3kg:')], - [$this->equalTo('----------:---------------------------------------')] + [$this->equalTo('----------_nWfzGiCgLczv3SSUzXL3kg:')], + [$this->equalTo('----------_---------------------------------------')] ); $cache->hasItem(str_repeat('-', 40)); @@ -46,7 +46,7 @@ public function testLongKeyVersioning() $reflectionMethod->setAccessible(true); // No versioning enabled - $this->assertEquals('--------------------------:------------', $reflectionMethod->invokeArgs($cache, [str_repeat('-', 12)])); + $this->assertEquals('--------------------------_------------', $reflectionMethod->invokeArgs($cache, [str_repeat('-', 12)])); $this->assertLessThanOrEqual(50, \strlen($reflectionMethod->invokeArgs($cache, [str_repeat('-', 12)]))); $this->assertLessThanOrEqual(50, \strlen($reflectionMethod->invokeArgs($cache, [str_repeat('-', 23)]))); $this->assertLessThanOrEqual(50, \strlen($reflectionMethod->invokeArgs($cache, [str_repeat('-', 40)]))); @@ -56,7 +56,7 @@ public function testLongKeyVersioning() $reflectionProperty->setValue($cache, true); // Versioning enabled - $this->assertEquals('--------------------------:1/------------', $reflectionMethod->invokeArgs($cache, [str_repeat('-', 12)])); + $this->assertEquals('--------------------------_1/------------', $reflectionMethod->invokeArgs($cache, [str_repeat('-', 12)])); $this->assertLessThanOrEqual(50, \strlen($reflectionMethod->invokeArgs($cache, [str_repeat('-', 12)]))); $this->assertLessThanOrEqual(50, \strlen($reflectionMethod->invokeArgs($cache, [str_repeat('-', 23)]))); $this->assertLessThanOrEqual(50, \strlen($reflectionMethod->invokeArgs($cache, [str_repeat('-', 40)])));