1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-03 23:37:39 +02:00

[ticket/11832] Create phpbb_symfony_request to handle initiating symfony_request

Now symfony_request is also a service (removed the function
phpbb_create_symfony_request).

Inject symfony request into filesystem

Cleanup for the tests

PHPBB3-11832
This commit is contained in:
Nathan Guse
2013-09-13 09:52:02 -05:00
parent a194e6ce7a
commit aa710df2db
7 changed files with 110 additions and 75 deletions

View File

@@ -5708,44 +5708,3 @@ function phpbb_convert_30_dbms_to_31($dbms)
throw new \RuntimeException("You have specified an invalid dbms driver: $dbms");
}
/**
* Create a Symfony Request object from phpbb_request object
*
* @param phpbb_request $request Request object
* @return Request A Symfony Request object
*/
function phpbb_create_symfony_request(phpbb_request $request)
{
// If we have already gotten it, don't go back through all the trouble of
// creating it again; instead, just return it. This allows multiple calls
// of this method so we don't have to globalize $symfony_request in other
// functions.
static $symfony_request;
if (null !== $symfony_request)
{
return $symfony_request;
}
// This function is meant to sanitize the global input arrays
$sanitizer = function(&$value, $key) {
$type_cast_helper = new phpbb_request_type_cast_helper();
$type_cast_helper->set_var($value, $value, gettype($value), true);
};
// We need to re-enable the super globals so we can access them here
$request->enable_super_globals();
$get_parameters = $_GET;
$post_parameters = $_POST;
$server_parameters = $_SERVER;
$files_parameters = $_FILES;
$cookie_parameters = $_COOKIE;
// And now disable them again for security
$request->disable_super_globals();
array_walk_recursive($get_parameters, $sanitizer);
array_walk_recursive($post_parameters, $sanitizer);
$symfony_request = new Symfony\Component\HttpFoundation\Request($get_parameters, $post_parameters, array(), $cookie_parameters, $files_parameters, $server_parameters);
return $symfony_request;
}