mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-10 13:28:55 +00:00
[ticket/10080] Allow resetting the request instance used by request_var.
PHPBB3-10080
This commit is contained in:
parent
cda3ba62b9
commit
458b8841eb
2 changed files with 25 additions and 2 deletions
|
@ -48,11 +48,16 @@ function set_var(&$result, $var, $type, $multibyte = false)
|
||||||
* Default is false, causing all bytes outside the ASCII range (0-127) to be replaced with question marks
|
* Default is false, causing all bytes outside the ASCII range (0-127) to be replaced with question marks
|
||||||
* @param bool $cookie This param is mapped to phpbb_request_interface::COOKIE as the last param for
|
* @param bool $cookie This param is mapped to phpbb_request_interface::COOKIE as the last param for
|
||||||
* phpbb_request_interface::variable for backwards compatability reasons.
|
* phpbb_request_interface::variable for backwards compatability reasons.
|
||||||
|
* @param phpbb_request_interface|null|false If an instance of phpbb_request_interface is given the instance is stored in
|
||||||
|
* a static variable and used for all further calls where this parameters is null. Until
|
||||||
|
* the function is called with an instance it automatically creates a new phpbb_request
|
||||||
|
* instance on every call. By passing false this per-call instantiation can be restored
|
||||||
|
* after having passed in a phpbb_request_interface instance.
|
||||||
*
|
*
|
||||||
* @return mixed The value of $_REQUEST[$var_name] run through {@link set_var set_var} to ensure that the type is the
|
* @return mixed The value of $_REQUEST[$var_name] run through {@link set_var set_var} to ensure that the type is the
|
||||||
* the same as that of $default. If the variable is not set $default is returned.
|
* the same as that of $default. If the variable is not set $default is returned.
|
||||||
*/
|
*/
|
||||||
function request_var($var_name, $default, $multibyte = false, $cookie = false, phpbb_request_interface $request = null)
|
function request_var($var_name, $default, $multibyte = false, $cookie = false, $request = null)
|
||||||
{
|
{
|
||||||
// This is all just an ugly hack to add "Dependency Injection" to a function
|
// This is all just an ugly hack to add "Dependency Injection" to a function
|
||||||
// the only real code is the function call which maps this function to a method.
|
// the only real code is the function call which maps this function to a method.
|
||||||
|
@ -67,6 +72,15 @@ function request_var($var_name, $default, $multibyte = false, $cookie = false, p
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if ($request === false)
|
||||||
|
{
|
||||||
|
$static_request = null;
|
||||||
|
|
||||||
|
if (empty($var_name))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$tmp_request = $static_request;
|
$tmp_request = $static_request;
|
||||||
|
|
||||||
|
@ -3253,7 +3267,7 @@ function get_preg_expression($mode)
|
||||||
* Depends on whether installed PHP version supports unicode properties
|
* Depends on whether installed PHP version supports unicode properties
|
||||||
*
|
*
|
||||||
* @param string $word word template to be replaced
|
* @param string $word word template to be replaced
|
||||||
* @param bool $use_unicode whether or not to take advantage of PCRE supporting unicode
|
* @param bool $use_unicode whether or not to take advantage of PCRE supporting unicode
|
||||||
*
|
*
|
||||||
* @return string $preg_expr regex to use with word censor
|
* @return string $preg_expr regex to use with word censor
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -12,6 +12,15 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php';
|
||||||
|
|
||||||
class phpbb_request_var_test extends phpbb_test_case
|
class phpbb_request_var_test extends phpbb_test_case
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Makes sure request_var has its standard behaviour.
|
||||||
|
*/
|
||||||
|
protected function setUp()
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
request_var(false, false, false, false, false);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider request_variables
|
* @dataProvider request_variables
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Reference in a new issue