Req #42608 [Opn]: Example #660 (filter_input_array) is wrong
| From: | datibbaw@php.net | Date: | Wed, 22 Feb 2012 13:29:09 +0000 |
| Subject: | Req #42608 [Opn]: Example #660 (filter_input_array) is wrong | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-167731@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=42608&edit=1
ID: 42608
Updated by: datibbaw@php.net
Reported by: phpbugs dot 20 dot zsh at spamgourmet dot com
Summary: Example #660 (filter_input_array) is wrong
Status: Open
Type: Feature/Change Request
Package: Filter related
Operating System: Irrelevant
PHP Version: 5.2.4
Block user comment: N
Private report: N
New Comment:
Fast forward to 2012, this is still wrong IMHO
Possible bugs:
1) documentation problem; the return value is defined as an array or false in case of failure - when
the respective INPUT_XXX is not populated, it returns null; clearly not expected according to the
documentation.
2) wrong behaviour in the code; if INPUT_XXX is not populated, I would expect the return value to be
this: array_fill_keys(array_keys($definition), null)
Previous Comments:
------------------------------------------------------------------------
[2009-10-08 03:02:44] ChadFulton at gmail dot com
Although this is a very old bug, it seems to me that the poster is
incorrect; I suspect the problem is that the poster attempted to set the
$_POST array during runtime (e.g. $_POST = array( ... ); ), and
filter_input_array does not allow runtime modification $_POST, $_GET,
etc.
------------------------------------------------------------------------
[2007-09-10 11:04:44] phpbugs dot 20 dot zsh at spamgourmet dot com
Description:
------------
The example will not output the array shown below the example code -- any undefined variable will
cause filter_input_array() to return (so the output would be "NULL").
You'll notice I've classified this as a change request rather than a documentation
problem, for the expected (and described ("Return Values")) behavior in example #660 makes
WAY more sense.
Reproduce code:
---------------
http://www.php.net/filter_input_array
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=42608&edit=1