Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Proxy __destruct issue #258

@malinink

Description

@malinink

Hi,

I use PM in my ZF2 project, and all works correct, but I found one problem, fix me please if I am wrong.

I create Lazy Service and do not use it in particular case, but I call Proxy of that service which I pass to another object.

At the and of application someone (I suppose GC) call __destruct on object, that cause Proxy to init proxy object. It is not behaviour I expected.

So my question is: Is that normal?

Stack trace from exception from Factory of proxy object

#   Time    Memory  Function    Location
1   0.0519  3225752 ProxyManagerGeneratedProxy\__PM__\Zend\Log\Logger\Generated309fa39f737280002e5d4e613b403125->__destruct( )  ../ProxyManagerGeneratedProxy__PM__ZendLogLoggerGenerated309fa39f737280002e5d4e613b403125.php:0
2   0.0520  3226280 __invoke ( )    ../ProxyManagerGeneratedProxy__PM__ZendLogLoggerGenerated309fa39f737280002e5d4e613b403125.php:32
3   0.0520  3226392 Zend\ServiceManager\Proxy\LazyServiceFactory->Zend\ServiceManager\Proxy\{closure}( )    ../ProxyManagerGeneratedProxy__PM__ZendLogLoggerGenerated309fa39f737280002e5d4e613b403125.php:32
4   0.0520  3226520 call_user_func ( )  ../LazyServiceFactory.php:57
5   0.0520  3226552 Zend\ServiceManager\ServiceManager->Zend\ServiceManager\{closure}( )    ../LazyServiceFactory.php:57
6   0.0520  3226552 Zend\ServiceManager\ServiceManager->doCreate( ) ../ServiceManager.php:1194
7   0.0520  3226600 Zend\ServiceManager\ServiceManager->createFromFactory( )    ../ServiceManager.php:638
8   0.0523  3235680 Zend\ServiceManager\ServiceManager->createServiceViaCallback( ) ../ServiceManager.php:1097 

I thought that it will be better do not nothing at that case. (if proxy object is not instanced already)

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions