Skip to content

Commit a04fe5f

Browse files
committed
Making Router::reverse() strip out additional framework internal parameters that are specific to requestAction. Refs #977
1 parent 8119f77 commit a04fe5f

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

cake/libs/router.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1045,6 +1045,9 @@ function queryString($q, $extra = array(), $escape = false) {
10451045
* Since parsed URL's contain additional 'pass' and 'named' as well as 'url.url' keys.
10461046
* Those keys need to be specially handled in order to reverse a params array into a string url.
10471047
*
1048+
* This will strip out 'autoRender', 'bare', 'requested', and 'return' param names as those
1049+
* are used for CakePHP internals and should not normally be part of an output url.
1050+
*
10481051
* @param array $param The params array that needs to be reversed.
10491052
* @return string The string that is the reversed result of the array
10501053
* @access public
@@ -1054,7 +1057,10 @@ function reverse($params) {
10541057
$pass = $params['pass'];
10551058
$named = $params['named'];
10561059
$url = $params['url'];
1057-
unset($params['pass'], $params['named'], $params['paging'], $params['models'], $params['url'], $url['url']);
1060+
unset(
1061+
$params['pass'], $params['named'], $params['paging'], $params['models'], $params['url'], $url['url'],
1062+
$params['autoRender'], $params['bare'], $params['requested'], $params['return']
1063+
);
10581064
$params = array_merge($params, $pass, $named);
10591065
if (!empty($url)) {
10601066
$params['?'] = $url;

cake/tests/cases/libs/router.test.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2059,7 +2059,11 @@ function testRouterReverse() {
20592059
'action' => 'view',
20602060
'pass' => array(1),
20612061
'named' => array(),
2062-
'url' => array()
2062+
'url' => array(),
2063+
'autoRender' => 1,
2064+
'bare' => 1,
2065+
'return' => 1,
2066+
'requested' => 1
20632067
);
20642068
$result = Router::reverse($params);
20652069
$this->assertEqual($result, '/posts/view/1');

0 commit comments

Comments
 (0)