-
Notifications
You must be signed in to change notification settings - Fork 2.5k
[ServiceManager] Implemented circular alias reference detection #5100
Conversation
ServiceManagers that allow overwriting the service definition may contain circular references which will cause an infinite loop. Extracted alias resolving code to a protected method that will detect circular references.
@tux-rampage wouldn't it be easier to handle this kind of logic in |
@@ -810,4 +810,25 @@ public function testUsesMultipleDelegates() | |||
$this->assertInstanceOf('stdClass', array_shift($fooDelegator->instances)); | |||
$this->assertSame($fooDelegator, array_shift($barDelegator->instances)); | |||
} | |||
|
|||
/** | |||
* @covers Zend\ServiceMnager\ServiceManager::resolveAlias |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo ServiceMnager instead of ServiceManager, miss 'a' after 'M'
@Ocramius Might need to think about it. It's not as easy as putting it in the resolve logics. We should also keep in mind that $aliases is a protected and not a private member. So derived classes may manipulate it aside from setAlias(). |
@Ocramius It might be doable in the |
@Ocramius I added a cycle check to setAlias() as well and modified the unit test accordingly |
[ServiceManager] Implemented circular alias reference detection
- one argument per line (sprintf call)
…sm-cyclic-alias-ref [ServiceManager] Implemented circular alias reference detection
- one argument per line (sprintf call)
ServiceManagers that allow overwriting the service definition may
contain circular references which will cause an infinite loop.
I extracted the alias resolving code to a protected method that will detect
circular references and throw an exception if one is encountered.