mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
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:
parent
1c8ec459b6
commit
17782f71b3
2 changed files with 4 additions and 6 deletions
|
@ -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]];
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue