Skip to content
This repository
Browse code

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 authored March 24, 2012
4  lib/Cake/Core/Object.php
@@ -80,6 +80,9 @@ public function requestAction($url, $extra = array()) {
80 80
 		$data = isset($extra['data']) ? $extra['data'] : null;
81 81
 		unset($extra['data']);
82 82
 
  83
+		if (is_string($url) && strpos($url, FULL_BASE_URL) === 0) {
  84
+			$url = Router::normalize(str_replace(FULL_BASE_URL, '', $url));
  85
+		}
83 86
 		if (is_string($url)) {
84 87
 			$request = new CakeRequest($url);
85 88
 		} elseif (is_array($url)) {
@@ -90,7 +93,6 @@ public function requestAction($url, $extra = array()) {
90 93
 		if (isset($data)) {
91 94
 			$request->data = $data;
92 95
 		}
93  
-
94 96
 		$dispatcher = new Dispatcher();
95 97
 		$result = $dispatcher->dispatch($request, new CakeResponse(), $extra);
96 98
 		Router::popRequest();
4  lib/Cake/Test/Case/Core/ObjectTest.php
@@ -465,6 +465,10 @@ public function testRequestAction() {
465 465
 		$expected = 'This is a test';
466 466
 		$this->assertEquals($expected, $result);
467 467
 
  468
+		$result = $this->object->requestAction(FULL_BASE_URL . '/request_action/test_request_action');
  469
+		$expected = 'This is a test';
  470
+		$this->assertEquals($expected, $result);
  471
+
468 472
 		$result = $this->object->requestAction('/request_action/another_ra_test/2/5');
469 473
 		$expected = 7;
470 474
 		$this->assertEquals($expected, $result);

0 notes on commit fca8b1d

Please sign in to comment.
Something went wrong with that request. Please try again.