Skip to content

Commit bcda9e5

Browse files
committed
Merge branch '4.4' into 5.1
* 4.4: [Cache] Psr16Cache does not handle Proxy cache items [Serializer] fixed fix encoding of cache keys with anonymous classes Bump Symfony version to 4.4.13 Update VERSION for 4.4.12 Update CHANGELOG for 4.4.12 Bump Symfony version to 3.4.45 Update VERSION for 3.4.44 Update CONTRIBUTORS for 3.4.44 Update CHANGELOG for 3.4.44
2 parents a2c913f + f8e1211 commit bcda9e5

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

Mapping/Factory/CacheClassMetadataFactory.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ public function getMetadataFor($value)
5151
return $this->loadedClasses[$class];
5252
}
5353

54-
// Key cannot contain backslashes according to PSR-6
55-
$key = strtr($class, '\\', '_');
54+
$key = rawurlencode(strtr($class, '\\', '_'));
5655

5756
$item = $this->cacheItemPool->getItem($key);
5857
if ($item->isHit()) {

Tests/Mapping/Factory/CacheMetadataFactoryTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,20 @@ public function testInvalidClassThrowsException()
6363

6464
$factory->getMetadataFor('Not\Exist');
6565
}
66+
67+
public function testAnonymousClass()
68+
{
69+
$anonymousObject = new class() {
70+
};
71+
72+
$metadata = new ClassMetadata(\get_class($anonymousObject));
73+
$decorated = $this->getMockBuilder(ClassMetadataFactoryInterface::class)->getMock();
74+
$decorated
75+
->expects($this->once())
76+
->method('getMetadataFor')
77+
->willReturn($metadata);
78+
79+
$factory = new CacheClassMetadataFactory($decorated, new ArrayAdapter());
80+
$this->assertEquals($metadata, $factory->getMetadataFor($anonymousObject));
81+
}
6682
}

0 commit comments

Comments
 (0)