Skip to content

Commit

Permalink
Fixed Router::url() not being able to leave an URL with persist param…
Browse files Browse the repository at this point in the history
…eters
  • Loading branch information
jippi committed Nov 16, 2009
1 parent 2cb0c3a commit f078b0a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions cake/libs/router.php
Expand Up @@ -859,6 +859,7 @@ function url($url = null, $full = false) {
$plugin = $url['plugin'];
}

$_url = $url;
$url = array_merge(array('controller' => $params['controller'], 'plugin' => $params['plugin']), Set::filter($url, true));

if ($plugin !== false) {
Expand All @@ -878,7 +879,13 @@ function url($url = null, $full = false) {
$originalUrl = $url;

if (isset($route[4]['persist'], $_this->__params[0])) {
$url = array_merge(array_intersect_key($params, Set::combine($route[4]['persist'], '/')), $url);
foreach($route[4]['persist'] as $_key) {
if (array_key_exists($_key, $_url)) {
$url[$_key] = $_url[$_key];
} elseif (array_key_exists($_key, $params)) {
$url[$_key] = $params[$_key];
}
}
}
if ($match = $_this->mapRouteElements($route, $url)) {
$output = trim($match, '/');
Expand All @@ -890,7 +897,7 @@ function url($url = null, $full = false) {

$named = $args = array();
$skip = array_merge(
array('bare', 'action', 'controller', 'plugin', 'ext', '?', '#', 'prefix'),
array('bare', 'action', 'controller', 'plugin', 'ext', '?', '#', 'prefix'),
$_this->__prefixes
);

Expand Down

0 comments on commit f078b0a

Please sign in to comment.