1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-04-02 23:12:46 +02:00

[ticket/14875] Use raw_variable() method in _variable() to get raw data

The raw_variable() method uses the same exact code the _variable method
has been using until now.

PHPBB3-14875
This commit is contained in:
Marc Alexander 2016-11-25 22:51:29 +01:00
parent 9aa017d0f7
commit 08bf8812d3
No known key found for this signature in database
GPG Key ID: 50E0D2423696F995

View File

@ -431,41 +431,14 @@ class request implements \phpbb\request\request_interface
*/
protected function _variable($var_name, $default, $multibyte = false, $super_global = \phpbb\request\request_interface::REQUEST, $trim = true)
{
$path = false;
$var = $this->raw_variable($var_name, $default, $super_global);
// deep direct access to multi dimensional arrays
if (is_array($var_name))
// Return prematurely if raw variable is empty array or the same as
// the default. Using strict comparison to ensure that one can't
// prevent proper type checking on any input variable
if ($var === array() || $var === $default)
{
$path = $var_name;
// make sure at least the variable name is specified
if (empty($path))
{
return (is_array($default)) ? array() : $default;
}
// the variable name is the first element on the path
$var_name = array_shift($path);
}
if (!isset($this->input[$super_global][$var_name]))
{
return (is_array($default)) ? array() : $default;
}
$var = $this->input[$super_global][$var_name];
if ($path)
{
// walk through the array structure and find the element we are looking for
foreach ($path as $key)
{
if (is_array($var) && isset($var[$key]))
{
$var = $var[$key];
}
else
{
return (is_array($default)) ? array() : $default;
}
}
return $var;
}
$this->type_cast_helper->recursive_set_var($var, $default, $multibyte, $trim);