Browse files

Fixing a failing test.

  • Loading branch information...
1 parent 21dd7fd commit e36631091dbeefdd599ba42e844c2fb1e745491d @markstory markstory committed Dec 1, 2009
Showing with 9 additions and 2 deletions.
  1. +9 −2 cake/libs/router.php
View
11 cake/libs/router.php
@@ -756,6 +756,7 @@ function url($url = null, $full = false) {
}
$backupUrl = $url;
+ //$url += array('controller' => $params['controller'], 'plugin' => $params['plugin'])
$url = array_merge(
array('controller' => $params['controller'], 'plugin' => $params['plugin']),
Set::filter($url, true)
@@ -1374,6 +1375,7 @@ function match($url) {
return false;
}
+ //remove defaults that are also keys. They can cause match failures
$count = count($this->keys);
while ($count--) {
unset($defaults[$this->keys[$count]]);
@@ -1392,7 +1394,7 @@ function match($url) {
}
$i++;
}
- $passedArgsAndParams = array_diff_key($diff, $defaults, $keyNames);
+ $passedArgsAndParams = array_diff_key($diff, array_filter($defaults), $keyNames);
list($named, $params) = Router::getNamedElements($passedArgsAndParams, $url['controller'], $url['action']);
//remove any pass params, they have numeric indexes, skip any params that are in the defaults
@@ -1407,7 +1409,12 @@ function match($url) {
unset($url[$i], $params[$i]);
$i++;
}
-
+
+ //still some left over parameters that weren't named or passed args, bail.
+ if (!empty($params)) {
+ return false;
+ }
+
//check patterns for routed params
if (!empty($this->params)) {
foreach ($this->params as $key => $pattern) {

0 comments on commit e366310

Please sign in to comment.