From cdc70fc4270fe97a4761b03daba552cd92911cc1 Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 14 Aug 2012 12:43:24 -0400 Subject: [PATCH] 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 --- lib/Cake/Controller/Component/RequestHandlerComponent.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/Cake/Controller/Component/RequestHandlerComponent.php b/lib/Cake/Controller/Component/RequestHandlerComponent.php index 544e01cd1..d731c2885 100644 --- a/lib/Cake/Controller/Component/RequestHandlerComponent.php +++ b/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]); }