From 17782f71b3510ac195f65293f09264204f13d18c Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 29 Sep 2009 22:53:17 -0400 Subject: [PATCH] Removing internal magic 'id' param. It behaved inconsistently in that it defaulted into the passed parameters, even though it was input as a named/routed parameter. This change makes 'id' a regular routed/named parameter. --- cake/libs/router.php | 4 +--- cake/tests/cases/libs/router.test.php | 6 +++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/cake/libs/router.php b/cake/libs/router.php index 83375588d..274313d71 100644 --- a/cake/libs/router.php +++ b/cake/libs/router.php @@ -899,9 +899,7 @@ class Router { // Remove this once parsed URL parameters can be inserted into 'pass' for ($i = 0; $i < $count; $i++) { - if ($i === 0 && is_numeric($keys[$i]) && in_array('id', $keys)) { - $args[0] = $url[$keys[$i]]; - } elseif (is_numeric($keys[$i]) || $keys[$i] === 'id') { + if (is_numeric($keys[$i])) { $args[] = $url[$keys[$i]]; } else { $named[$keys[$i]] = $url[$keys[$i]]; diff --git a/cake/tests/cases/libs/router.test.php b/cake/tests/cases/libs/router.test.php index 5e4439d18..2bcb2a26d 100644 --- a/cake/tests/cases/libs/router.test.php +++ b/cake/tests/cases/libs/router.test.php @@ -686,7 +686,7 @@ class RouterTest extends CakeTestCase { Router::parse('/'); - $result = Router::url(array('plugin' => null, 'controller' => 'pages', 'action' => 'edit', 'id' => '284')); + $result = Router::url(array('plugin' => null, 'controller' => 'pages', 'action' => 'edit', 284)); $expected = '/admin/pages/edit/284'; $this->assertEqual($result, $expected); @@ -706,7 +706,7 @@ class RouterTest extends CakeTestCase { Router::parse('/'); $result = Router::url(array( - 'plugin' => 'shows', 'controller' => 'show_tickets', 'action' => 'edit', 'id' => '6', + 'plugin' => 'shows', 'controller' => 'show_tickets', 'action' => 'edit', 6, 'admin' => true, 'prefix' => 'admin' )); $expected = '/admin/shows/show_tickets/edit/6'; @@ -1297,7 +1297,7 @@ class RouterTest extends CakeTestCase { $expected = '/12/file:asdf.png'; $this->assertEqual($result, $expected); - $result = Router::url(array('controller' => 'graphs', 'action' => 'view', 'id' => 12, 'file' => 'asdf.foo')); + $result = Router::url(array('controller' => 'graphs', 'action' => 'view', 12, 'file' => 'asdf.foo')); $expected = '/graphs/view/12/file:asdf.foo'; $this->assertEqual($result, $expected);