Bug #70263 [NEW]: filter_input_array 'add_empty' fails if query string absent

From: Date: Thu, 13 Aug 2015 22:24:33 +0000
Subject: Bug #70263 [NEW]: filter_input_array 'add_empty' fails if query string absent
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-195194@lists.php.net to get a copy of this message
From: mike dot whipps at littlevale dot co dot uk Operating system: Linux Fedora 20 PHP version: 5.5.28 Package: Filter related Bug Type: Bug Bug description:filter_input_array 'add_empty' fails if query string absent 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 bug report at https://bugs.php.net/bug.php?id=70263&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=70263&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=70263&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=70263&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=70263&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=70263&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=70263&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=70263&r=needscript Try newer version: https://bugs.php.net/fix.php?id=70263&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=70263&r=support Expected behavior: https://bugs.php.net/fix.php?id=70263&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=70263&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=70263&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=70263&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=70263&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=70263&r=dst IIS Stability: https://bugs.php.net/fix.php?id=70263&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=70263&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=70263&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=70263&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=70263&r=mysqlcfg

« previous php.bugs (#195194) next »