Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Fix infinite loop when chaining peering service managers #7296

Closed
wants to merge 1 commit into from
Closed

Fix infinite loop when chaining peering service managers #7296

wants to merge 1 commit into from

Conversation

fabiang
Copy link
Contributor

@fabiang fabiang commented Mar 5, 2015

Hello,

we have a use case where we add a peering service manager (SM) to the SM of an ZF2 application. Also the peering SM becomes the SM of the application added as peering SM, which allows us to call services from the applications SM.

For services which can't be found this runs into a infinite loop. The applications SM calls the peering SM, which calls back the application SM and so on.

This PR tries to fix that by passing the current SM instance to the peering SM so they skip the caller SM when looping over peeringServiceManagers.

@fabiang
Copy link
Contributor Author

fabiang commented Mar 6, 2015

  • made test for chained service managers more clear
  • reset instance after calling has/get on peering service manager
  • remove method, only use protected variable


/**
* @covers Zend\ServiceManager\ServiceManager::loopPeeringServiceManagers
* @covers Zend\ServiceManager\ServiceManager::setServiceManagerCaller
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two statements are causing PHPUnit errors to occur; it looks like PHPUnit does not like @covers for non-public methods: https://travis-ci.org/zendframework/zf2/jobs/53314224#L486

I'll remove the statements during merge.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its ok to @cover non-public methods, but the given one didnt exists any more.

if ($caller !== $peeringServiceManager) {
$peeringServiceManager->serviceManagerCaller = $this;
if ($peeringServiceManager->has($name)) {
return true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't $peeringServiceManager->serviceManagerCaller be reset to null before returning?

weierophinney added a commit that referenced this pull request Mar 10, 2015
Fix infinite loop when chaining peering service managers
weierophinney added a commit that referenced this pull request Mar 10, 2015
- Continue early in loops.
- Ensure `$peeringServiceManager->serviceManagerCaller` is reset before
  returning from a loop.
- Remove `@covers` and `@uses` annotations which were raising errors.
weierophinney added a commit that referenced this pull request Mar 10, 2015
@weierophinney
Copy link
Member

Merged to develop for release with 2.4.

@fabiang
Copy link
Contributor Author

fabiang commented Mar 10, 2015

thank you, 👍

@fabiang fabiang deleted the infinite-loop-sm-peering branch March 10, 2015 21:03
weierophinney added a commit to zendframework/zend-servicemanager that referenced this pull request May 15, 2015
…nite-loop-sm-peering

Fix infinite loop when chaining peering service managers
weierophinney added a commit to zendframework/zend-servicemanager that referenced this pull request May 15, 2015
- Continue early in loops.
- Ensure `$peeringServiceManager->serviceManagerCaller` is reset before
  returning from a loop.
- Remove `@covers` and `@uses` annotations which were raising errors.
weierophinney added a commit to zendframework/zend-servicemanager that referenced this pull request May 15, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants