diff --git a/src/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php b/src/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php index b326a30c50..6aeb65d0e6 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php @@ -217,10 +217,6 @@ class InlineServiceDefinitionsPass extends AbstractRecursivePass implements Repe return false; } - if ($isReferencedByConstructor && $this->container->getDefinition($srcId)->isLazy() && ($definition->getProperties() || $definition->getMethodCalls() || $definition->getConfigurator())) { - return false; - } - return $this->container->getDefinition($srcId)->isShared(); } } diff --git a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php index 8e0e3528ec..96b0812479 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php @@ -655,6 +655,7 @@ EOF; $autowired = $definition->isAutowired() ? ' autowired' : ''; if ($definition->isLazy()) { + unset($this->circularReferences[$id]); $lazyInitialization = '$lazyLoad = true'; } else { $lazyInitialization = ''; diff --git a/src/Symfony/Component/Form/AbstractType.php b/src/Symfony/Component/Form/AbstractType.php index 3509db5d94..1a9cfd75be 100644 --- a/src/Symfony/Component/Form/AbstractType.php +++ b/src/Symfony/Component/Form/AbstractType.php @@ -52,7 +52,7 @@ abstract class AbstractType implements FormTypeInterface */ public function getBlockPrefix() { - return StringUtil::fqcnToBlockPrefix(\get_class($this)); + return StringUtil::fqcnToBlockPrefix(\get_class($this)) ?: ''; } /** diff --git a/src/Symfony/Component/Security/Core/Exception/CustomUserMessageAuthenticationException.php b/src/Symfony/Component/Security/Core/Exception/CustomUserMessageAuthenticationException.php index 505dd2c735..5db47013d4 100644 --- a/src/Symfony/Component/Security/Core/Exception/CustomUserMessageAuthenticationException.php +++ b/src/Symfony/Component/Security/Core/Exception/CustomUserMessageAuthenticationException.php @@ -60,7 +60,7 @@ class CustomUserMessageAuthenticationException extends AuthenticationException */ public function serialize() { - return serialize([parent::serialize(true), $this->messageKey, $this->messageData]); + $serialized = [parent::serialize(true), $this->messageKey, $this->messageData]; return $this->doSerialize($serialized, \func_num_args() ? \func_get_arg(0) : null); } diff --git a/src/Symfony/Component/Security/Core/Tests/Exception/CustomUserMessageAuthenticationExceptionTest.php b/src/Symfony/Component/Security/Core/Tests/Exception/CustomUserMessageAuthenticationExceptionTest.php index d69d3bffcb..32c76a452f 100644 --- a/src/Symfony/Component/Security/Core/Tests/Exception/CustomUserMessageAuthenticationExceptionTest.php +++ b/src/Symfony/Component/Security/Core/Tests/Exception/CustomUserMessageAuthenticationExceptionTest.php @@ -15,6 +15,21 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Security\Core\Authentication\Token\AnonymousToken; use Symfony\Component\Security\Core\Exception\CustomUserMessageAuthenticationException; +class ChildCustomUserMessageAuthenticationException extends CustomUserMessageAuthenticationException +{ + public function serialize() + { + return serialize([$this->childMember, parent::serialize()]); + } + + public function unserialize($str) + { + list($this->childMember, $parentData) = unserialize($str); + + parent::unserialize($parentData); + } +} + class CustomUserMessageAuthenticationExceptionTest extends TestCase { public function testConstructWithSAfeMessage() @@ -39,4 +54,18 @@ class CustomUserMessageAuthenticationExceptionTest extends TestCase $this->assertEquals($token, $processed->getMessageData()['token']); $this->assertSame($processed->getToken(), $processed->getMessageData()['token']); } + + public function testSharedSerializedDataFromChild() + { + $token = new AnonymousToken('foo', 'bar'); + + $exception = new ChildCustomUserMessageAuthenticationException(); + $exception->childMember = $token; + $exception->setToken($token); + + $processed = unserialize(serialize($exception)); + $this->assertEquals($token, $processed->childMember); + $this->assertEquals($token, $processed->getToken()); + $this->assertSame($processed->getToken(), $processed->childMember); + } }