PR 1698 has caused circular dependency issue

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

PR 1698 has caused circular dependency issue

SocalNick
https://github.com/zendframework/zf2/pull/1698

I agree with the fix to ServiceManager::has, as Pieter Kokx explained, has would return false while get would return a perfectly valid instance. With the fix to DiAbstractServiceFactory::canCreateServiceWithName, has will return true if Di can create the requested class.

However, the DiFactory configures DiAbstractServiceFactory to USE_SL_BEFORE_DI. Now that has returns true for a class that can be instantiated with Di, the second half of this conditional returns true, resulting in a circular dependency exception to be thrown by SM: https://github.com/zendframework/zf2/blob/master/library/Zend/ServiceManager/Di/DiServiceFactory.php#L87

So it seems we need to fix DiServiceFactory, but not exactly sure what that fix would be. To be honest, I'm not sure why DiServiceFactory has an instance of the locator...

If this is confusing, catch me on IRC.


-Nick (@SocalNick)
Reply | Threaded
Open this post in threaded view
|

Re: PR 1698 has caused circular dependency issue

Marco Pivetta
Ouch, this is quite a big problem...
I'm not sure how to fix this either, but something like tracking "visited" factories in the ServiceManager could work.
The problem is that the API becomes quite a mess...
Anyone having hints?

Marco Pivetta

http://twitter.com/Ocramius     

http://marco-pivetta.com    



On 2 July 2012 21:19, Nicholas Calugar <[hidden email]> wrote:
https://github.com/zendframework/zf2/pull/1698

I agree with the fix to ServiceManager::has, as Pieter Kokx explained, has would return false while get would return a perfectly valid instance. With the fix to DiAbstractServiceFactory::canCreateServiceWithName, has will return true if Di can create the requested class.

However, the DiFactory configures DiAbstractServiceFactory to USE_SL_BEFORE_DI. Now that has returns true for a class that can be instantiated with Di, the second half of this conditional returns true, resulting in a circular dependency exception to be thrown by SM: https://github.com/zendframework/zf2/blob/master/library/Zend/ServiceManager/Di/DiServiceFactory.php#L87

So it seems we need to fix DiServiceFactory, but not exactly sure what that fix would be. To be honest, I'm not sure why DiServiceFactory has an instance of the locator...

If this is confusing, catch me on IRC.


-Nick (@SocalNick)