From 1326d207923299a125f8ac43d80a1650393054f4 Mon Sep 17 00:00:00 2001 From: nate Date: Fri, 24 Aug 2007 13:11:31 +0000 Subject: [PATCH] Router fix for breaking out of plugins (Ticket #3106) git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5577 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/libs/router.php | 9 +++++++++ cake/tests/cases/libs/router.test.php | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/cake/libs/router.php b/cake/libs/router.php index 71f5ce2a8..559a845fa 100644 --- a/cake/libs/router.php +++ b/cake/libs/router.php @@ -674,8 +674,17 @@ class Router extends Object { } } + $plugin = false; + if (array_key_exists('plugin', $url)) { + $plugin = $url['plugin']; + } + $url = am(array('controller' => $params['controller'], 'plugin' => $params['plugin']), Set::filter($url, true)); + if ($plugin !== false) { + $url['plugin'] = $plugin; + } + if (isset($url['ext'])) { $extension = '.' . $url['ext']; unset($url['ext']); diff --git a/cake/tests/cases/libs/router.test.php b/cake/tests/cases/libs/router.test.php index d1148c732..135759c0d 100644 --- a/cake/tests/cases/libs/router.test.php +++ b/cake/tests/cases/libs/router.test.php @@ -368,6 +368,24 @@ class RouterTest extends UnitTestCase { $result = $this->router->url(array('admin' => true, 'controller' => 'pages', 'action' => 'view', 'my-page')); $expected = '/page/my-page'; $this->assertEqual($result, $expected); + + $this->router->reload(); + + $this->router->setRequestInfo(array( + array( + 'pass' => array(), 'action' => 'index', 'plugin' => 'myplugin', 'controller' => 'mycontroller', + 'admin' => false, 'url' => array('url' => array()), 'bare' => 0, 'webservices' => '' + ), + array( + 'base' => '/', 'here' => '/', + 'webroot' => '/', 'passedArgs' => array(), 'namedArgs' => array(), + 'webservices' => null + ) + )); + + $result = $this->router->url(array('plugin' => null, 'controller' => 'myothercontroller')); + $expected = '/myothercontroller/'; + $this->assertEqual($result, $expected); } function testUrlGenerationWithExtensions() {