Skip to content

Commit

Permalink
Making Router::reverse() strip out additional framework internal para…
Browse files Browse the repository at this point in the history
…meters that are specific to requestAction. Refs #977
  • Loading branch information
markstory committed Aug 5, 2010
1 parent 8119f77 commit a04fe5f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
8 changes: 7 additions & 1 deletion cake/libs/router.php
Expand Up @@ -1045,6 +1045,9 @@ function queryString($q, $extra = array(), $escape = false) {
* Since parsed URL's contain additional 'pass' and 'named' as well as 'url.url' keys.
* Those keys need to be specially handled in order to reverse a params array into a string url.
*
* This will strip out 'autoRender', 'bare', 'requested', and 'return' param names as those
* are used for CakePHP internals and should not normally be part of an output url.
*
* @param array $param The params array that needs to be reversed.
* @return string The string that is the reversed result of the array
* @access public
Expand All @@ -1054,7 +1057,10 @@ function reverse($params) {
$pass = $params['pass'];
$named = $params['named'];
$url = $params['url'];
unset($params['pass'], $params['named'], $params['paging'], $params['models'], $params['url'], $url['url']);
unset(
$params['pass'], $params['named'], $params['paging'], $params['models'], $params['url'], $url['url'],
$params['autoRender'], $params['bare'], $params['requested'], $params['return']
);
$params = array_merge($params, $pass, $named);
if (!empty($url)) {
$params['?'] = $url;
Expand Down
6 changes: 5 additions & 1 deletion cake/tests/cases/libs/router.test.php
Expand Up @@ -2059,7 +2059,11 @@ function testRouterReverse() {
'action' => 'view',
'pass' => array(1),
'named' => array(),
'url' => array()
'url' => array(),
'autoRender' => 1,
'bare' => 1,
'return' => 1,
'requested' => 1
);
$result = Router::reverse($params);
$this->assertEqual($result, '/posts/view/1');
Expand Down

0 comments on commit a04fe5f

Please sign in to comment.