mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Fix missing query arguments in array urls.
Adding documented features that previously wasn't implemented. Fixes #3328
This commit is contained in:
parent
093275aef6
commit
9ce70044b0
2 changed files with 25 additions and 3 deletions
|
@ -73,9 +73,13 @@ class Object {
|
|||
$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 @@ class Object {
|
|||
} 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();
|
||||
|
|
|
@ -619,6 +619,24 @@ class ObjectTest extends CakeTestCase {
|
|||
$this->assertEquals($expected, $result['named']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 @@ class ObjectTest extends CakeTestCase {
|
|||
'item' => 'value'
|
||||
));
|
||||
$result = $this->object->requestAction(array('controller' => 'request_action', 'action' => 'post_pass'));
|
||||
$expected = null;
|
||||
$this->assertEmpty($result);
|
||||
|
||||
$result = $this->object->requestAction(
|
||||
|
|
Loading…
Reference in a new issue