mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Fixing issue where named params equal to null/false would be part of the generated url.
This commit is contained in:
parent
6ef8203d54
commit
8d404332a2
2 changed files with 12 additions and 1 deletions
|
@ -267,7 +267,7 @@ class CakeRoute {
|
|||
$named = $pass = $diff = array();
|
||||
foreach ($url as $key => $value) {
|
||||
// pull out named params so comparisons later on are faster.
|
||||
if ($key[0] === ':') {
|
||||
if ($key[0] === ':' && ($value !== false && $value !== null)) {
|
||||
$named[substr($key, 1)] = $value;
|
||||
unset($url[$key]);
|
||||
continue;
|
||||
|
|
|
@ -338,6 +338,17 @@ class CakeRouteTestCase extends CakeTestCase {
|
|||
$this->assertFalse($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* test that named params with null/false are excluded
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testNamedParamsWithNullFalse() {
|
||||
$route = new CakeRoute('/:controller/:action/*', array('plugin' => null));
|
||||
$result = $route->match(array('controller' => 'posts', 'action' => 'index', ':page' => null, 'sort' => false));
|
||||
$this->assertEquals('/posts/index/', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* test that match with patterns works.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue