From 1939384f2aa8bcd947000113940c005072622d59 Mon Sep 17 00:00:00 2001 From: Scott Aubrey Date: Thu, 14 Jan 2016 17:05:42 +0000 Subject: [PATCH 1/3] add a test for broken use case --- test/ServiceManagerTest.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/ServiceManagerTest.php b/test/ServiceManagerTest.php index 716c9b91..31b9f445 100644 --- a/test/ServiceManagerTest.php +++ b/test/ServiceManagerTest.php @@ -245,6 +245,17 @@ public function testGetWithAlias() $this->assertEquals('bar', $this->serviceManager->get('baz')); } + /** + * @covers Zend\ServiceManager\ServiceManager::get + */ + public function testGetWithAliasofAliasWithCanonicalizedName() + { + $this->serviceManager->setService('Foo', 'Bar'); + $this->serviceManager->setAlias('Baz', 'Foo'); + $this->serviceManager->setAlias('Qux', 'Baz'); + $this->assertEquals('Bar', $this->serviceManager->get('Qux')); + } + /** * @covers Zend\ServiceManager\ServiceManager::get */ From d01978aaeeb20a0b08aac8603617fe833653d9bf Mon Sep 17 00:00:00 2001 From: Scott Aubrey Date: Thu, 14 Jan 2016 17:15:10 +0000 Subject: [PATCH 2/3] canonicalize the alias name when retrieving the key from the aliases array --- src/ServiceManager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ServiceManager.php b/src/ServiceManager.php index 89ce2ad0..91cf5ac9 100644 --- a/src/ServiceManager.php +++ b/src/ServiceManager.php @@ -477,7 +477,7 @@ protected function resolveAlias($cName) } $stack[$cName] = $cName; - $cName = $this->aliases[$cName]; + $cName = $this->aliases[$this->canonicalizeName($cName)]; } return $cName; From a31054d7cbf2ea18b7bf1774c29bcaa6860a7e23 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Tue, 19 Jan 2016 15:01:12 -0600 Subject: [PATCH 3/3] Added CHANGELOG for #71 --- CHANGELOG.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a71922e..92bfe1b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ All notable changes to this project will be documented in this file, in reverse chronological order by release. -## 2.7.4 - TBD +## 2.7.4 - 2015-01-19 ### Added @@ -18,7 +18,9 @@ All notable changes to this project will be documented in this file, in reverse ### Fixed -- Nothing. +- [#71](https://github.com/zendframework/zend-servicemanager/pull/71) fixes an edge case + with alias usage, whereby an alias of an alias was not being resolved to the + final service name. ## 2.7.3 - 2016-01-13