Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix missing query arguments in array urls.

Adding documented features that previously wasn't implemented.

Fixes #3328
  • Loading branch information...
commit 9ce70044b0d73e1a9fe52c28b8df454f0d3bebe7 1 parent 093275a
@markstory markstory authored
Showing with 25 additions and 3 deletions.
  1. +7 −2 lib/Cake/Core/Object.php
  2. +18 −1 lib/Cake/Test/Case/Core/ObjectTest.php
View
9 lib/Cake/Core/Object.php
@@ -73,9 +73,13 @@ public function requestAction($url, $extra = array()) {
$extra['autoRender'] = 1;
unset($extra[$index]);
}
- if (is_array($url) && !isset($extra['url'])) {
+ $arrayUrl = is_array($url);
+ if ($arrayUrl && !isset($extra['url'])) {
$extra['url'] = array();
}
+ if ($arrayUrl && !isset($extra['data'])) {
+ $extra['data'] = array();
+ }
$extra = array_merge(array('autoRender' => 0, 'return' => 1, 'bare' => 1, 'requested' => 1), $extra);
$data = isset($extra['data']) ? $extra['data'] : null;
unset($extra['data']);
@@ -88,11 +92,12 @@ public function requestAction($url, $extra = array()) {
} elseif (is_array($url)) {
$params = $url + array('pass' => array(), 'named' => array(), 'base' => false);
$params = array_merge($params, $extra);
- $request = new CakeRequest(Router::reverse($params), false);
+ $request = new CakeRequest(Router::reverse($params));
}
if (isset($data)) {
$request->data = $data;
}
+
$dispatcher = new Dispatcher();
$result = $dispatcher->dispatch($request, new CakeResponse(), $extra);
Router::popRequest();
View
19 lib/Cake/Test/Case/Core/ObjectTest.php
@@ -620,6 +620,24 @@ public function testRequestActionParamParseAndPass() {
}
/**
+ * Test that requestAction handles get parameters correctly.
+ *
+ * @return void
+ */
+ public function testRequestActionGetParameters() {
+ $result = $this->object->requestAction(
+ '/request_action/params_pass?get=value&limit=5'
+ );
+ $this->assertEquals('value', $result->query['get']);
+
+ $result = $this->object->requestAction(
+ array('controller' => 'request_action', 'action' => 'params_pass'),
+ array('url' => array('get' => 'value', 'limit' => 5))
+ );
+ $this->assertEquals('value', $result->query['get']);
+ }
+
+/**
* test that requestAction does not fish data out of the POST
* superglobal.
*
@@ -632,7 +650,6 @@ public function testRequestActionNoPostPassing() {
'item' => 'value'
));
$result = $this->object->requestAction(array('controller' => 'request_action', 'action' => 'post_pass'));
- $expected = null;
$this->assertEmpty($result);
$result = $this->object->requestAction(
Please sign in to comment.
Something went wrong with that request. Please try again.