Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[HttpFoundation] Complete Request::overrideGlobals

  • Loading branch information...
commit b217897ecb2582904a8834ca3fa87051e342d10d 1 parent 4bb65c7
@stealth35 stealth35 authored
Showing with 11 additions and 5 deletions.
  1. +11 −5 src/Symfony/Component/HttpFoundation/Request.php
View
16 src/Symfony/Component/HttpFoundation/Request.php
@@ -397,7 +397,8 @@ public function __toString()
/**
* Overrides the PHP global variables according to this request instance.
*
- * It overrides $_GET, $_POST, $_REQUEST, $_SERVER, $_COOKIE, and $_FILES.
+ * It overrides $_GET, $_POST, $_REQUEST, $_SERVER, $_COOKIE.
+ * $_FILES is never override, see rfc1867
*
* @api
*/
@@ -407,7 +408,6 @@ public function overrideGlobals()
$_POST = $this->request->all();
$_SERVER = $this->server->all();
$_COOKIE = $this->cookies->all();
- // FIXME: populate $_FILES
foreach ($this->headers->all() as $key => $value) {
$key = strtoupper(str_replace('-', '_', $key));
@@ -418,9 +418,15 @@ public function overrideGlobals()
}
}
- // FIXME: should read variables_order and request_order
- // to know which globals to merge and in which order
- $_REQUEST = array_merge($_GET, $_POST);
+ $request = array('g' => $_GET, 'p' => $_POST, 'c' => $_COOKIE);
+
+ $request_order = ini_get('request_order') ?: ini_get('variable_order');
+ $request_order = preg_replace('#[^cgp]#', '', strtolower($request_order)) ?: 'gp';
+
+ $_REQUEST = array();
+ foreach (str_split($request_order) as $order) {
+ $_REQUEST = array_merge($_REQUEST, $request[$order]);
+ }
}
/**
Please sign in to comment.
Something went wrong with that request. Please try again.