Skip to content
This repository has been archived by the owner on May 16, 2018. It is now read-only.

Fixed 'Undefined index' #695

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions library/Zend/Controller/Router/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
}
}

Expand Down
13 changes: 13 additions & 0 deletions tests/Zend/Controller/Router/Route/ChainTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down