Skip to content
Permalink
Browse files

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.
  • Loading branch information...
markstory committed Sep 30, 2009
1 parent 1c8ec45 commit 17782f71b3510ac195f65293f09264204f13d18c
Showing with 4 additions and 6 deletions.
  1. +1 −3 cake/libs/router.php
  2. +3 −3 cake/tests/cases/libs/router.test.php
@@ -899,9 +899,7 @@ function url($url = null, $full = false) {
// 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]];
@@ -686,7 +686,7 @@ function testUrlGeneration() {
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 @@ function testUrlGeneration() {
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 @@ function testNamedArgsUrlGeneration() {
$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);

0 comments on commit 17782f7

Please sign in to comment.
You can’t perform that action at this time.