mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 00:48:25 +00:00
Making route matching fail even faster. This gives significant performance boosts to routes not matching.
This commit is contained in:
parent
756b09849f
commit
3b0a3d4109
2 changed files with 6 additions and 4 deletions
|
@ -265,7 +265,7 @@ class CakeRoute {
|
|||
|
||||
//check that all the key names are in the url
|
||||
$keyNames = array_flip($this->keys);
|
||||
if (array_intersect_key($keyNames, $url) != $keyNames) {
|
||||
if (array_intersect_key($keyNames, $url) !== $keyNames) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -287,6 +287,7 @@ class CakeRoute {
|
|||
// keys that exist in the defaults and have different values cause match failures.
|
||||
$keyExists = array_key_exists($key, $defaults);
|
||||
if ($keyExists && $defaults[$key] != $value) {
|
||||
return false;
|
||||
$diff[$key] = $value;
|
||||
continue;
|
||||
}
|
||||
|
@ -308,6 +309,7 @@ class CakeRoute {
|
|||
|
||||
// keys that don't exist are different.
|
||||
if (!$keyExists && !empty($value)) {
|
||||
return false;
|
||||
$diff[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -219,7 +219,7 @@ class CakeRouteTestCase extends CakeTestCase {
|
|||
* @return void
|
||||
**/
|
||||
function testMatchBasic() {
|
||||
/* $route = new CakeRoute('/:controller/:action/:id', array('plugin' => null));
|
||||
$route = new CakeRoute('/:controller/:action/:id', array('plugin' => null));
|
||||
$result = $route->match(array('controller' => 'posts', 'action' => 'view', 'plugin' => null));
|
||||
$this->assertFalse($result);
|
||||
|
||||
|
@ -235,7 +235,7 @@ class CakeRouteTestCase extends CakeTestCase {
|
|||
|
||||
$result = $route->match(array('controller' => 'pages', 'action' => 'display', 'about'));
|
||||
$this->assertFalse($result);
|
||||
*/
|
||||
|
||||
|
||||
$route = new CakeRoute('/pages/*', array('controller' => 'pages', 'action' => 'display'));
|
||||
$result = $route->match(array('controller' => 'pages', 'action' => 'display', 'home'));
|
||||
|
@ -369,7 +369,7 @@ class CakeRouteTestCase extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testNamedParamsWithNullFalse() {
|
||||
$route = new CakeRoute('/:controller/:action/*', array('plugin' => null));
|
||||
$route = new CakeRoute('/:controller/:action/*');
|
||||
$result = $route->match(array('controller' => 'posts', 'action' => 'index', ':page' => null, 'sort' => false));
|
||||
$this->assertEquals('/posts/index/', $result);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue