mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Fix issue where requestAction() would not strip base url.
requestAction + Controller::referer() don't work well together. Stripping the base domain, and normalizing the URL gives an application request which works much better. This keeps RequestHandler more transparent when overloading redirects. Fixes #2711
This commit is contained in:
parent
16bde9c723
commit
fca8b1dd30
2 changed files with 7 additions and 1 deletions
|
@ -80,6 +80,9 @@ class Object {
|
||||||
$data = isset($extra['data']) ? $extra['data'] : null;
|
$data = isset($extra['data']) ? $extra['data'] : null;
|
||||||
unset($extra['data']);
|
unset($extra['data']);
|
||||||
|
|
||||||
|
if (is_string($url) && strpos($url, FULL_BASE_URL) === 0) {
|
||||||
|
$url = Router::normalize(str_replace(FULL_BASE_URL, '', $url));
|
||||||
|
}
|
||||||
if (is_string($url)) {
|
if (is_string($url)) {
|
||||||
$request = new CakeRequest($url);
|
$request = new CakeRequest($url);
|
||||||
} elseif (is_array($url)) {
|
} elseif (is_array($url)) {
|
||||||
|
@ -90,7 +93,6 @@ class Object {
|
||||||
if (isset($data)) {
|
if (isset($data)) {
|
||||||
$request->data = $data;
|
$request->data = $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
$dispatcher = new Dispatcher();
|
$dispatcher = new Dispatcher();
|
||||||
$result = $dispatcher->dispatch($request, new CakeResponse(), $extra);
|
$result = $dispatcher->dispatch($request, new CakeResponse(), $extra);
|
||||||
Router::popRequest();
|
Router::popRequest();
|
||||||
|
|
|
@ -465,6 +465,10 @@ class ObjectTest extends CakeTestCase {
|
||||||
$expected = 'This is a test';
|
$expected = 'This is a test';
|
||||||
$this->assertEquals($expected, $result);
|
$this->assertEquals($expected, $result);
|
||||||
|
|
||||||
|
$result = $this->object->requestAction(FULL_BASE_URL . '/request_action/test_request_action');
|
||||||
|
$expected = 'This is a test';
|
||||||
|
$this->assertEquals($expected, $result);
|
||||||
|
|
||||||
$result = $this->object->requestAction('/request_action/another_ra_test/2/5');
|
$result = $this->object->requestAction('/request_action/another_ra_test/2/5');
|
||||||
$expected = 7;
|
$expected = 7;
|
||||||
$this->assertEquals($expected, $result);
|
$this->assertEquals($expected, $result);
|
||||||
|
|
Loading…
Reference in a new issue