Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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
  • Loading branch information...
commit fca8b1dd3054c2155e17ddc1f91a47d23bc881af 1 parent 16bde9c
Mark Story markstory authored
4 lib/Cake/Core/Object.php
View
@@ -80,6 +80,9 @@ public function requestAction($url, $extra = array()) {
$data = isset($extra['data']) ? $extra['data'] : null;
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)) {
$request = new CakeRequest($url);
} elseif (is_array($url)) {
@@ -90,7 +93,6 @@ public function requestAction($url, $extra = array()) {
if (isset($data)) {
$request->data = $data;
}
-
$dispatcher = new Dispatcher();
$result = $dispatcher->dispatch($request, new CakeResponse(), $extra);
Router::popRequest();
4 lib/Cake/Test/Case/Core/ObjectTest.php
View
@@ -465,6 +465,10 @@ public function testRequestAction() {
$expected = 'This is a test';
$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');
$expected = 7;
$this->assertEquals($expected, $result);
Please sign in to comment.
Something went wrong with that request. Please try again.