Bug #70263 [Com]: filter_input_array 'add_empty' fails if query string absent
| From: | vorbox+php at pp dot me | Date: | Fri, 01 Nov 2019 13:22:38 +0000 |
| Subject: | Bug #70263 [Com]: filter_input_array 'add_empty' fails if query string absent | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-223545@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=70263&edit=1
ID: 70263
Comment by: vorbox+php at pp dot me
Reported by: mike dot whipps at littlevale dot co dot uk
Summary: filter_input_array 'add_empty' fails if query string
absent
Status: Open
Type: Bug
Package: Filter related
Operating System: Linux Fedora 20
PHP Version: 5.5.28
Block user comment: N
Private report: N
New Comment:
confirmed PHP7.4.0RC5 Windows 7 32.
Previous Comments:
------------------------------------------------------------------------
[2015-08-13 22:24:32] mike dot whipps at littlevale dot co dot uk
Description:
------------
filter_input_array(INPUT_GET, $filters, true) does not add empty fields to the output array if the
query string is absent. It does add them correctly if even one parameter appears.
Note that filter_var_array($_GET, $filters, true) does add the empty fields correctly.
Test script:
---------------
$getFilters = [
'id'=>['filter'=>FILTER_VALIDATE_INT,
'flags'=>FILTER_REQUIRE_SCALAR,
'options'=>['min_range'=>1]
],
'name'=>FILTER_UNSAFE_RAW
];
echo '$_GET: <br>';
var_dump($_GET);
$req = filter_input_array(INPUT_GET, $getFilters, true);
echo '<hr>$req:<br>';
var_dump($req);
echo '<hr>$reqGet<br>';
$reqGet = filter_var_array($_GET, $getFilters, true);
var_dump($reqGet);
Actual result:
--------------
Execute the above script with no query string gives this result:
$_GET:
array (size=0)
empty
$req:
null
$reqGet
array (size=2)
'id' => null
'name' => null
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=70263&edit=1