Permalink
Browse files

Making Router::reverse() strip out additional framework internal para…

…meters that are specific to requestAction. Refs #977
  • Loading branch information...
1 parent 8119f77 commit a04fe5f81d02b3e831e8e6b83e4353d9e39550e3 @markstory markstory committed Aug 5, 2010
Showing with 12 additions and 2 deletions.
  1. +7 −1 cake/libs/router.php
  2. +5 −1 cake/tests/cases/libs/router.test.php
View
@@ -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
@@ -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;
@@ -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');

0 comments on commit a04fe5f

Please sign in to comment.