Skip to content

Commit bd1022c

Browse files
committed
[PropertyInfo] Deal with not serializable context
1 parent 436f650 commit bd1022c

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/Symfony/Component/PropertyInfo/PropertyInfoExtractorCacheDecorator.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,14 @@ public function getTypes($class, $property, array $context = array())
9999
*/
100100
private function extract($method, array $arguments)
101101
{
102-
$key = $method.serialize($arguments);
102+
try {
103+
$serializedArguments = serialize($arguments);
104+
} catch (\Exception $exception) {
105+
// If arguments are not serializable, skip the cache
106+
return call_user_func_array(array($this->propertyInfoExtractor, $method), $arguments);
107+
}
108+
109+
$key = $method.$serializedArguments;
103110

104111
if (isset($this->arrayCache[$key])) {
105112
return $this->arrayCache[$key];

src/Symfony/Component/PropertyInfo/Tests/PropertyInfoExtractorCacheDecoratorTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,9 @@ public function testCache()
3131
$this->assertSame('short', $this->propertyInfo->getShortDescription('Foo', 'bar', array()));
3232
$this->assertSame('short', $this->propertyInfo->getShortDescription('Foo', 'bar', array()));
3333
}
34+
35+
public function testNotSerializableContext()
36+
{
37+
$this->assertSame('short', $this->propertyInfo->getShortDescription('Foo', 'bar', array('foo' => function () {})));
38+
}
3439
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy