mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Removing extra 0 index in request parameters.
When using requestAction with the return parameter, there would be an extra 0 index element that would create incorrect routes in the requestedAction. Fixes #2067
This commit is contained in:
parent
2cc9523509
commit
ea113922bd
2 changed files with 26 additions and 12 deletions
|
@ -65,8 +65,10 @@ class Object {
|
|||
return false;
|
||||
}
|
||||
App::uses('Dispatcher', 'Routing');
|
||||
if (in_array('return', $extra, true)) {
|
||||
$extra = array_merge($extra, array('return' => 0, 'autoRender' => 1));
|
||||
if (($index = array_search('return', $extra)) !== false) {
|
||||
$extra['return'] = 0;
|
||||
$extra['autoRender'] = 1;
|
||||
unset($extra[$index]);
|
||||
}
|
||||
if (is_array($url) && !isset($extra['url'])) {
|
||||
$extra['url'] = array();
|
||||
|
|
|
@ -124,7 +124,16 @@ class RequestActionController extends Controller {
|
|||
* @return array
|
||||
*/
|
||||
public function params_pass() {
|
||||
return $this->params;
|
||||
return $this->request;
|
||||
}
|
||||
|
||||
public function param_check() {
|
||||
$this->autoRender = false;
|
||||
$content = '';
|
||||
if (isset($this->request->params[0])) {
|
||||
$content = 'return found';
|
||||
}
|
||||
$this->response->body($content);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -564,6 +573,18 @@ class ObjectTest extends CakeTestCase {
|
|||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that requestAction() does not forward the 0 => return value.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testRequestActionRemoveReturnParam() {
|
||||
$result = $this->object->requestAction(
|
||||
'/request_action/param_check', array('return')
|
||||
);
|
||||
$this->assertEquals('', $result, 'Return key was found');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that requestAction() is populating $this->params properly
|
||||
*
|
||||
|
@ -615,13 +636,4 @@ class ObjectTest extends CakeTestCase {
|
|||
|
||||
$_POST = $_tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* testCakeError
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testCakeError() {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue