Skip to content

Commit e41c408

Browse files
committed
Adding parameter pattern matching back into RouterRoute::match(), fixes failing tests in RouterRoute test case.
1 parent 5999264 commit e41c408

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

cake/libs/router.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,7 +1384,6 @@ function match($url) {
13841384
$passedArgsAndParams = array_diff_key($diff, $this->defaults, $keyNames);
13851385
list($named, $params) = Router::getNamedElements($passedArgsAndParams, $url['controller'], $url['action']);
13861386

1387-
13881387
//remove any pass params, they have numeric indexes
13891388
$pass = array();
13901389
$i = 0;
@@ -1393,8 +1392,16 @@ function match($url) {
13931392
unset($url[$i]);
13941393
$i++;
13951394
}
1396-
return $this->_writeUrl(array_merge($url, compact('pass', 'named', 'prefix')));
13971395

1396+
//check patterns for routed params
1397+
if (!empty($this->params)) {
1398+
foreach ($this->params as $key => $pattern) {
1399+
if (array_key_exists($key, $url) && !preg_match('#' . $pattern . '#', $url[$key])) {
1400+
return false;
1401+
}
1402+
}
1403+
}
1404+
return $this->_writeUrl(array_merge($url, compact('pass', 'named', 'prefix')));
13981405

13991406
//*/
14001407
/*
@@ -1426,12 +1433,7 @@ function match($url) {
14261433
unset($params[$key]);
14271434
}
14281435
}
1429-
debug($params);
14301436
list($named, $params) = Router::getNamedElements($params);
1431-
debug($named);
1432-
debug($params);
1433-
debug($this);
1434-
echo '-----------<br>';
14351437
14361438
if (!strpos($this->template, '*') && (!empty($pass) || !empty($named))) {
14371439
return false;

cake/tests/cases/libs/router.test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1948,7 +1948,7 @@ function testRouterConnectDefaults() {
19481948
}
19491949
}
19501950

1951-
SimpleTest::ignore('RouterTest');
1951+
// SimpleTest::ignore('RouterTest');
19521952
// SimpleTest::ignore('RouterRouteTestCase');
19531953
/**
19541954
* Test case for RouterRoute

0 commit comments

Comments
 (0)