diff --git a/library/Zend/Controller/Router/Route.php b/library/Zend/Controller/Router/Route.php index 927b97b3d3..52c850e9b9 100644 --- a/library/Zend/Controller/Router/Route.php +++ b/library/Zend/Controller/Router/Route.php @@ -324,8 +324,10 @@ public function match($path, $partial = false) if (!array_key_exists($var, $return)) { return false; } elseif ($return[$var] == '' || $return[$var] === null) { - // Empty variable? Replace with the default value. - $return[$var] = $this->_defaults[$var]; + if (isset($this->_defaults[$var])) { + // Empty variable? Replace with the default value. + $return[$var] = $this->_defaults[$var]; + } } } diff --git a/tests/Zend/Controller/Router/Route/ChainTest.php b/tests/Zend/Controller/Router/Route/ChainTest.php index 95134cb104..3a0438c4d3 100644 --- a/tests/Zend/Controller/Router/Route/ChainTest.php +++ b/tests/Zend/Controller/Router/Route/ChainTest.php @@ -799,6 +799,19 @@ public function testChainingStaticDynamicMatchToDefaults() $this->assertEquals(0, $res['bar']); } + public function testChainingStaticDynamicMatchToNoDefaults() + { + $foo = new Zend_Controller_Router_Route_Static('foo'); + $bar = new Zend_Controller_Router_Route(':bar', array()); + $chain = $foo->chain($bar); + + $request = new Zend_Controller_Router_ChainTest_Request('http://www.zend.com/foo'); + $res = $chain->match($request); + + $this->assertTrue(is_array($res), 'Route did not match'); + $this->assertEquals('', $res['bar']); + } + /** * @group ZF-7368 */