From a04fe5f81d02b3e831e8e6b83e4353d9e39550e3 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 4 Aug 2010 23:35:49 -0400 Subject: [PATCH] Making Router::reverse() strip out additional framework internal parameters that are specific to requestAction. Refs #977 --- cake/libs/router.php | 8 +++++++- cake/tests/cases/libs/router.test.php | 6 +++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/cake/libs/router.php b/cake/libs/router.php index 0865c3703..b9cc68130 100644 --- a/cake/libs/router.php +++ b/cake/libs/router.php @@ -1045,6 +1045,9 @@ class Router { * 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 @@ class Router { $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; diff --git a/cake/tests/cases/libs/router.test.php b/cake/tests/cases/libs/router.test.php index ff995499d..f44c32bdc 100644 --- a/cake/tests/cases/libs/router.test.php +++ b/cake/tests/cases/libs/router.test.php @@ -2059,7 +2059,11 @@ class RouterTest extends CakeTestCase { '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');