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.

This commit is contained in:
mark_story 2009-09-29 22:53:17 -04:00
parent 1c8ec459b6
commit 17782f71b3
2 changed files with 4 additions and 6 deletions

View file

@ -899,9 +899,7 @@ class Router {
// Remove this once parsed URL parameters can be inserted into 'pass' // Remove this once parsed URL parameters can be inserted into 'pass'
for ($i = 0; $i < $count; $i++) { for ($i = 0; $i < $count; $i++) {
if ($i === 0 && is_numeric($keys[$i]) && in_array('id', $keys)) { if (is_numeric($keys[$i])) {
$args[0] = $url[$keys[$i]];
} elseif (is_numeric($keys[$i]) || $keys[$i] === 'id') {
$args[] = $url[$keys[$i]]; $args[] = $url[$keys[$i]];
} else { } else {
$named[$keys[$i]] = $url[$keys[$i]]; $named[$keys[$i]] = $url[$keys[$i]];

View file

@ -686,7 +686,7 @@ class RouterTest extends CakeTestCase {
Router::parse('/'); 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'; $expected = '/admin/pages/edit/284';
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
@ -706,7 +706,7 @@ class RouterTest extends CakeTestCase {
Router::parse('/'); Router::parse('/');
$result = Router::url(array( $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' 'admin' => true, 'prefix' => 'admin'
)); ));
$expected = '/admin/shows/show_tickets/edit/6'; $expected = '/admin/shows/show_tickets/edit/6';
@ -1297,7 +1297,7 @@ class RouterTest extends CakeTestCase {
$expected = '/12/file:asdf.png'; $expected = '/12/file:asdf.png';
$this->assertEqual($result, $expected); $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'; $expected = '/graphs/view/12/file:asdf.foo';
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);