Skip to content

Commit

Permalink
Fixing Router::reverse() not correctly working with Request objects that
Browse files Browse the repository at this point in the history
contained query string parameters.
  • Loading branch information
markstory committed Jan 21, 2011
1 parent e64e299 commit 1c3e1df
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion cake/libs/router.php
Expand Up @@ -1084,11 +1084,14 @@ public static function queryString($q, $extra = array(), $escape = false) {
*/
public static function reverse($params) {
if ($params instanceof CakeRequest) {
$url = $params->query;
$params = $params->params;
} else {
$url = $params['url'];
}
$pass = $params['pass'];
$named = $params['named'];
$url = $params['url'];

unset(
$params['pass'], $params['named'], $params['paging'], $params['models'], $params['url'], $url['url'],
$params['autoRender'], $params['bare'], $params['requested'], $params['return']
Expand Down
4 changes: 3 additions & 1 deletion cake/tests/cases/libs/router.test.php
Expand Up @@ -2309,9 +2309,11 @@ function testRouterReverse() {
'action' => 'view',
'pass' => array(1),
'named' => array(),
'url' => array('url' => 'eng/posts/view/1')
));
$request->query = array('url' => 'eng/posts/view/1', 'test' => 'value');
$result = Router::reverse($request);
$expected = '/eng/posts/view/1?test=value';
$this->assertEquals($expected, $result);
}

/**
Expand Down

0 comments on commit 1c3e1df

Please sign in to comment.