mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Adding parameter pattern matching back into RouterRoute::match(), fixes failing tests in RouterRoute test case.
This commit is contained in:
parent
5999264f10
commit
e41c408378
2 changed files with 10 additions and 8 deletions
|
@ -1384,7 +1384,6 @@ class RouterRoute {
|
||||||
$passedArgsAndParams = array_diff_key($diff, $this->defaults, $keyNames);
|
$passedArgsAndParams = array_diff_key($diff, $this->defaults, $keyNames);
|
||||||
list($named, $params) = Router::getNamedElements($passedArgsAndParams, $url['controller'], $url['action']);
|
list($named, $params) = Router::getNamedElements($passedArgsAndParams, $url['controller'], $url['action']);
|
||||||
|
|
||||||
|
|
||||||
//remove any pass params, they have numeric indexes
|
//remove any pass params, they have numeric indexes
|
||||||
$pass = array();
|
$pass = array();
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
@ -1393,8 +1392,16 @@ class RouterRoute {
|
||||||
unset($url[$i]);
|
unset($url[$i]);
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
return $this->_writeUrl(array_merge($url, compact('pass', 'named', 'prefix')));
|
|
||||||
|
|
||||||
|
//check patterns for routed params
|
||||||
|
if (!empty($this->params)) {
|
||||||
|
foreach ($this->params as $key => $pattern) {
|
||||||
|
if (array_key_exists($key, $url) && !preg_match('#' . $pattern . '#', $url[$key])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $this->_writeUrl(array_merge($url, compact('pass', 'named', 'prefix')));
|
||||||
|
|
||||||
//*/
|
//*/
|
||||||
/*
|
/*
|
||||||
|
@ -1426,12 +1433,7 @@ class RouterRoute {
|
||||||
unset($params[$key]);
|
unset($params[$key]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
debug($params);
|
|
||||||
list($named, $params) = Router::getNamedElements($params);
|
list($named, $params) = Router::getNamedElements($params);
|
||||||
debug($named);
|
|
||||||
debug($params);
|
|
||||||
debug($this);
|
|
||||||
echo '-----------<br>';
|
|
||||||
|
|
||||||
if (!strpos($this->template, '*') && (!empty($pass) || !empty($named))) {
|
if (!strpos($this->template, '*') && (!empty($pass) || !empty($named))) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -1948,7 +1948,7 @@ class RouterTest extends CakeTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SimpleTest::ignore('RouterTest');
|
// SimpleTest::ignore('RouterTest');
|
||||||
// SimpleTest::ignore('RouterRouteTestCase');
|
// SimpleTest::ignore('RouterRouteTestCase');
|
||||||
/**
|
/**
|
||||||
* Test case for RouterRoute
|
* Test case for RouterRoute
|
||||||
|
|
Loading…
Reference in a new issue