Issue: Incorrect behavior of retrieveFromPeeringManagerFirst() in ServiceManager #3348

Closed
Deserved opened this Issue Jan 4, 2013 · 0 comments

Projects

None yet

2 participants

@Deserved
Deserved commented Jan 4, 2013

Link to open discussion: http://zend-framework-community.634137.n4.nabble.com/In-ServiceManager-for-peering-strange-behavior-td4658667.html#a4658671

Case scenario 1

$child = new ServiceManager();
$parent = $child->createScopedServiceManager();
$parent->setRetrieveFromPeeringManagerFirst(true);
$parent->setAllowOverride(true);

$child->setService("foo1", "boo2");
$parent->setService("foo1", "boo1");

//below returns "boo1", but expects "boo2"
var_dump($parent->get("foo1"));

Case scenario 2

$sm = new ServiceManager( );
$sm->setService("foo1", "boo1");
$sm2 = new ServiceManager();
$sm2->setRetrieveFromPeeringManagerFirst(true);
$sm2->setService("foo1", "boo2");
$sm2->addPeeringServiceManager($sm);

//below returns "boo2", but expects "boo1"
var_dump($sm2->get("foo1"));

The reason is that get(), firstly tries to retrieve instance from parent and than does search in peering SM.

Possible solution:
Would be change that firstly to search in peering SM and than try to get from parent $instances.

The possible headache:

SM = ServiceManager, picture that you have:

SM1 has child SM2, and both of them have retrieveFromPeeringManagerFirst() set to true.
SM2 has child SM3

SM1, SM2 and SM3 have key 'foo1'.

SM1 does not have control over SM2, but expects to have 'foo1' from SM2, but will get from SM3. It brings some headache for user over control for retrieving from peering.

@weierophinney weierophinney added a commit that referenced this issue Jan 14, 2013
@weierophinney weierophinney [#3348] Fix CS issues
- Trailing whitespace
ac29623
@weierophinney weierophinney added a commit that closed this issue Jan 14, 2013
@weierophinney weierophinney Merge branch 'hotfix/3348'
Close #3423
Fixes #3348
054f7a0
@weierophinney weierophinney added a commit to zendframework/zend-servicemanager that referenced this issue May 15, 2015
@weierophinney weierophinney [zendframework/zendframework#3348] Fix CS issues
- Trailing whitespace
39f68ab
@weierophinney weierophinney added a commit to zendframework/zend-servicemanager that referenced this issue May 15, 2015
@weierophinney weierophinney Merge branch 'hotfix/3348' 9f8afee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment