zendframework/zf2 — pull request #3237 by richardjennings (2012-12-17 13:37:22+00:00)
Title: [BUG] Service Manager Not Shared Duplicate new Instance with multiple Abstract Factories

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.