From 39b610d9ade575a1836b869de57f2d5f9b3e2ecd Mon Sep 17 00:00:00 2001 From: Jeremy Livingston Date: Wed, 28 Aug 2013 16:28:53 -0400 Subject: [PATCH] Clear lazy loading initializer after the service is successfully initialized --- .../LazyProxy/Instantiator/RuntimeInstantiator.php | 4 ++-- .../Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php | 4 ++-- .../Tests/LazyProxy/Fixtures/php/lazy_service.php | 4 ++-- .../Tests/LazyProxy/Fixtures/php/lazy_service_structure.txt | 4 ++-- .../Tests/LazyProxy/PhpDumper/ProxyDumperTest.php | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Symfony/Bridge/ProxyManager/LazyProxy/Instantiator/RuntimeInstantiator.php b/src/Symfony/Bridge/ProxyManager/LazyProxy/Instantiator/RuntimeInstantiator.php index 4364019345..789255554a 100644 --- a/src/Symfony/Bridge/ProxyManager/LazyProxy/Instantiator/RuntimeInstantiator.php +++ b/src/Symfony/Bridge/ProxyManager/LazyProxy/Instantiator/RuntimeInstantiator.php @@ -51,10 +51,10 @@ class RuntimeInstantiator implements InstantiatorInterface return $this->factory->createProxy( $definition->getClass(), function (&$wrappedInstance, LazyLoadingInterface $proxy) use ($realInstantiator) { - $proxy->setProxyInitializer(null); - $wrappedInstance = call_user_func($realInstantiator); + $proxy->setProxyInitializer(null); + return true; } ); diff --git a/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php b/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php index 05f3ae1bff..fd64f97e6f 100644 --- a/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php +++ b/src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/ProxyDumper.php @@ -75,10 +75,10 @@ class ProxyDumper implements DumperInterface $instantiation new $proxyClass( function (&\$wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface \$proxy) use (\$container) { - \$proxy->setProxyInitializer(null); - \$wrappedInstance = \$container->$methodName(false); + \$proxy->setProxyInitializer(null); + return true; } ); diff --git a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Fixtures/php/lazy_service.php b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Fixtures/php/lazy_service.php index e2158b8f9b..aba65e85f1 100644 --- a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Fixtures/php/lazy_service.php +++ b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Fixtures/php/lazy_service.php @@ -50,10 +50,10 @@ class LazyServiceProjectServiceContainer extends Container return $this->services['foo'] = new stdClass_c1d194250ee2e2b7d2eab8b8212368a8( function (& $wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface $proxy) use ($container) { - $proxy->setProxyInitializer(null); - $wrappedInstance = $container->getFooService(false); + $proxy->setProxyInitializer(null); + return true; } ); diff --git a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Fixtures/php/lazy_service_structure.txt b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Fixtures/php/lazy_service_structure.txt index e1831fd9fa..6bc1c6883b 100644 --- a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Fixtures/php/lazy_service_structure.txt +++ b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Fixtures/php/lazy_service_structure.txt @@ -10,10 +10,10 @@ class ProjectServiceContainer extends Container return $this->services['foo'] = new stdClass_%s( function (&$wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface $proxy) use ($container) { - $proxy->setProxyInitializer(null); - $wrappedInstance = $container->getFooService(false); + $proxy->setProxyInitializer(null); + return true; } ); diff --git a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php index 5fefbfac8c..7823c63be6 100644 --- a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php +++ b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/PhpDumper/ProxyDumperTest.php @@ -74,7 +74,7 @@ class ProxyDumperTest extends \PHPUnit_Framework_TestCase '%wif ($lazyLoad) {%w$container = $this;%wreturn $this->services[\'foo\'] = new ' . 'SymfonyBridgeProxyManagerLazyProxyTestsInstantiatorProxyDumperTest_%s(%wfunction ' . '(&$wrappedInstance, \ProxyManager\Proxy\LazyLoadingInterface $proxy) use ($container) {' - . '%w$proxy->setProxyInitializer(null);%w$wrappedInstance = $container->getFooService(false);' + . '%w$wrappedInstance = $container->getFooService(false);%w$proxy->setProxyInitializer(null);' . '%wreturn true;%w}%w);%w}%w', $code );