mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Making Router::reverse() strip out additional framework internal parameters that are specific to requestAction. Refs #977
This commit is contained in:
parent
8119f77659
commit
a04fe5f81d
2 changed files with 12 additions and 2 deletions
|
@ -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;
|
||||
|
|
|
@ -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');
|
||||
|
|
Loading…
Reference in a new issue