From c28ecff862475caf27dc6816fcdb5131f814d359 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 4 Aug 2010 23:44:48 -0400 Subject: [PATCH] Adding a test to ensure that $here contains the correct value when supplying additionalParams (like through a requestAction). Changing how Dispatcher::__extractParams converts url params into a string, so the result is the same as a string url. Removing the call to _stop() as it halts the script when a requestAction hits a cached file. Fixes #977 --- cake/dispatcher.php | 9 ++++++--- cake/tests/cases/dispatcher.test.php | 9 +++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/cake/dispatcher.php b/cake/dispatcher.php index 38ab045114e..1597c666f59 100644 --- a/cake/dispatcher.php +++ b/cake/dispatcher.php @@ -111,7 +111,7 @@ function dispatch($url = null, $additionalParams = array()) { $this->here = $this->base . '/' . $url; if ($this->asset($url) || $this->cached($url)) { - $this->_stop(); + return; } $controller =& $this->__getController(); @@ -227,8 +227,11 @@ function _invoke(&$controller, $params) { */ function __extractParams($url, $additionalParams = array()) { $defaults = array('pass' => array(), 'named' => array(), 'form' => array()); - $this->params = array_merge($defaults, $url, $additionalParams); - return Router::url($url); + $params = array_merge($defaults, $url, $additionalParams); + $this->params = $params; + + $params += array('base' => false, 'url' => array()); + return ltrim(Router::reverse($params), '/'); } /** diff --git a/cake/tests/cases/dispatcher.test.php b/cake/tests/cases/dispatcher.test.php index 8e9ed61eb30..42af1db2acb 100644 --- a/cake/tests/cases/dispatcher.test.php +++ b/cake/tests/cases/dispatcher.test.php @@ -1382,16 +1382,21 @@ function testDispatch() { */ function testDispatchWithArray() { $Dispatcher =& new TestDispatcher(); - Configure::write('App.baseUrl','/index.php'); $url = 'pages/home/param:value/param2:value2'; $url = array('controller' => 'pages', 'action' => 'display'); - $controller = $Dispatcher->dispatch($url, array('pass' => array('home'), 'named' => array('param' => 'value', 'param2' => 'value2'), 'return' => 1)); + $controller = $Dispatcher->dispatch($url, array( + 'pass' => array('home'), + 'named' => array('param' => 'value', 'param2' => 'value2'), + 'return' => 1 + )); $expected = 'Pages'; $this->assertEqual($expected, $controller->name); $expected = array('0' => 'home', 'param' => 'value', 'param2' => 'value2'); $this->assertIdentical($expected, $controller->passedArgs); + + $this->assertEqual($Dispatcher->base . '/pages/display/home/param:value/param2:value2', $Dispatcher->here); } /**