Browse Source

Make RequestHandlerComponent better simulate GET requests.

Modify the global state to simulate a GET request.  This avoids issues
where PUT data would be processed during simulated redirect.

Fixes #3113
mark_story 13 years ago
parent
commit
cdc70fc427
1 changed files with 2 additions and 0 deletions
  1. 2 0
      lib/Cake/Controller/Component/RequestHandlerComponent.php

+ 2 - 0
lib/Cake/Controller/Component/RequestHandlerComponent.php

@@ -217,6 +217,7 @@ class RequestHandlerComponent extends Component {
 
 /**
  * Handles (fakes) redirects for Ajax requests using requestAction()
+ * Modifies the $_POST and $_SERVER['REQUEST_METHOD'] to simulate a new GET request.
  *
  * @param Controller $controller A reference to the controller
  * @param string|array $url A string or array containing the redirect location
@@ -228,6 +229,7 @@ class RequestHandlerComponent extends Component {
 		if (!$this->request->is('ajax')) {
 			return;
 		}
+		$_SERVER['REQUEST_METHOD'] = 'GET';
 		foreach ($_POST as $key => $val) {
 			unset($_POST[$key]);
 		}