[BUG] Service Manager Not Shared Duplicate new Instance with multiple Abstract Factories #3237

Closed
wants to merge 7 commits into
from

Projects

None yet

3 participants

@richardjennings
Contributor

Added test: ZendTest\ServiceManager\ServiceManagerTest::testDuplicateNewInstanceMultipleAbstractFactories

Test fails with 1 error.

If an Abstract Factory cannot create an instance, a pendingAbstractFactoryRequests key is left set.

This pendingAbstractFactoryRequests key forces canCreateFromAbstractFactory to return false.

Fix suggestion supplied:
set $this->pendingAbstractFactoryRequests[get_class($abstractFactory)] = $requestedName;

only when $abstractFactory->canCreateServiceWithName($this, $canonicalName, $requestedName) returns true.

All Service Manager Tests pass with supplied fix.

Richard Jenn... added some commits Dec 17, 2012
@Ocramius Ocramius commented on an outdated diff Dec 17, 2012
library/Zend/ServiceManager/ServiceManager.php
if ($abstractFactory->canCreateServiceWithName($this, $canonicalName, $requestedName)) {
+ $this->pendingAbstractFactoryRequests[get_class($abstractFactory)] = $requestedName;
@Ocramius
Ocramius Dec 17, 2012 Member

Please fix CS.

Richard Jennings CS ac8f38b
@Ocramius Ocramius commented on an outdated diff Dec 17, 2012
tests/ZendTest/ServiceManager/ServiceManagerTest.php
@@ -654,4 +654,17 @@ public function testCanGetAliasedServicesFromPeeringServiceManagers()
$this->assertSame($service, $this->serviceManager->get('alias-name'));
}
+
+ /**
@Ocramius
Ocramius Dec 17, 2012 Member

Same here (CS) ;)

Richard Jenn... added some commits Dec 17, 2012
Richard Jennings CS 5ae1be2
Richard Jennings CS 9b4eafc
Richard Jennings remove trailing spaces 41563fe
Richard Jennings CS 7df22b4
@weierophinney weierophinney added a commit that referenced this pull request Dec 18, 2012
@weierophinney weierophinney Merge branch 'hotfix/3237' into develop
Forward port #3237
ff05338
@weierophinney weierophinney added a commit that closed this pull request Dec 18, 2012
@weierophinney weierophinney Merge branch 'hotfix/3237'
Close #3237
39eab55
@weierophinney weierophinney added a commit to zendframework/zend-servicemanager that referenced this pull request May 15, 2015
@weierophinney weierophinney Merge branch 'hotfix/3237' c36f6c0
@weierophinney weierophinney added a commit to zendframework/zend-servicemanager that referenced this pull request May 15, 2015
@weierophinney weierophinney Merge branch 'hotfix/3237' into develop d4be36e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment