Skip to content

Commit b8158ea

Browse files
committed
Changing namespace separator to _ to match PSR-16 allowed keys
1 parent 500fba8 commit b8158ea

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ abstract class AbstractAdapter implements AdapterInterface, CacheInterface, Logg
3434

3535
protected function __construct(string $namespace = '', int $defaultLifetime = 0)
3636
{
37-
$this->namespace = '' === $namespace ? '' : CacheItem::validateKey($namespace).':';
37+
$this->namespace = '' === $namespace ? '' : CacheItem::validateKey($namespace).'_';
3838
if (null !== $this->maxIdLength && \strlen($namespace) > $this->maxIdLength - 24) {
3939
throw new InvalidArgumentException(sprintf('Namespace must be %d chars max, %d given ("%s")', $this->maxIdLength - 24, \strlen($namespace), $namespace));
4040
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ public function testLongKey()
2626
$cache->expects($this->exactly(2))
2727
->method('doHave')
2828
->withConsecutive(
29-
[$this->equalTo('----------:nWfzGiCgLczv3SSUzXL3kg:')],
30-
[$this->equalTo('----------:---------------------------------------')]
29+
[$this->equalTo('----------_nWfzGiCgLczv3SSUzXL3kg:')],
30+
[$this->equalTo('----------_---------------------------------------')]
3131
);
3232

3333
$cache->hasItem(str_repeat('-', 40));
@@ -46,7 +46,7 @@ public function testLongKeyVersioning()
4646
$reflectionMethod->setAccessible(true);
4747

4848
// No versioning enabled
49-
$this->assertEquals('--------------------------:------------', $reflectionMethod->invokeArgs($cache, [str_repeat('-', 12)]));
49+
$this->assertEquals('--------------------------_------------', $reflectionMethod->invokeArgs($cache, [str_repeat('-', 12)]));
5050
$this->assertLessThanOrEqual(50, \strlen($reflectionMethod->invokeArgs($cache, [str_repeat('-', 12)])));
5151
$this->assertLessThanOrEqual(50, \strlen($reflectionMethod->invokeArgs($cache, [str_repeat('-', 23)])));
5252
$this->assertLessThanOrEqual(50, \strlen($reflectionMethod->invokeArgs($cache, [str_repeat('-', 40)])));
@@ -56,7 +56,7 @@ public function testLongKeyVersioning()
5656
$reflectionProperty->setValue($cache, true);
5757

5858
// Versioning enabled
59-
$this->assertEquals('--------------------------:1/------------', $reflectionMethod->invokeArgs($cache, [str_repeat('-', 12)]));
59+
$this->assertEquals('--------------------------_1/------------', $reflectionMethod->invokeArgs($cache, [str_repeat('-', 12)]));
6060
$this->assertLessThanOrEqual(50, \strlen($reflectionMethod->invokeArgs($cache, [str_repeat('-', 12)])));
6161
$this->assertLessThanOrEqual(50, \strlen($reflectionMethod->invokeArgs($cache, [str_repeat('-', 23)])));
6262
$this->assertLessThanOrEqual(50, \strlen($reflectionMethod->invokeArgs($cache, [str_repeat('-', 40)])));

0 commit comments

Comments
 (0)