Doc #42608 [Ver->Csd]: Example #660 (filter_input_array) is wrong
| From: | cmb@php.net | Date: | Sat, 05 May 2018 16:25:12 +0000 |
| Subject: | Doc #42608 [Ver->Csd]: Example #660 (filter_input_array) is wrong | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-15651@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: cmb@php.net
Reported by: phpbugs dot 20 dot zsh at spamgourmet dot com
Summary: Example #660 (filter_input_array) is wrong
-Status: Verified
+Status: Closed
Type: Documentation Problem
Package: Filter related
Operating System: Irrelevant
PHP Version: 5.2.4
Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.
Thank you for the report, and for helping us make our documentation better.This bug has b
Previous Comments:
------------------------------------------------------------------------
[2018-05-05 16:24:43] cmb@php.net
Automatic comment from SVN on behalf of cmb
Revision: http://svn.php.net/viewvc/?view=revision&revision=344963
Log: Fix #42608: Example 660 (filter_input_array) is wrong
------------------------------------------------------------------------
[2018-05-05 16:00:19] cmb@php.net
Changing the behavior of filter_input_array() for cases where
INPUT_* is not set would cause a BC break, and in my opinion would
therefore require the RFC process[1], since filter_input_array()
works this way since its introduction[2]. Thus, I'm changing to
doc bug.
It is also noteworthy to mention that filter_input_array() returns
FALSE, if the input array is not populated, and the
FILTER_NULL_ON_FAILURE flag is set in the $definition array[3].
Finally, indeed the example is seriously wrong.
[1] <https://wiki.php.net/rfc/howto>
[2] <https://3v4l.org/8qjcU>
[3] <https://3v4l.org/N9uDe>
------------------------------------------------------------------------
[2012-02-27 14:38:46] datibbaw@php.net
The following patch has been added/updated:
Patch Name: consistent_filter_input_array
Revision: 1330353526
URL: https://bugs.php.net/patch-display.php?bug=42608&patch=consistent_filter_input_array&revision=1330353526
------------------------------------------------------------------------
[2012-02-22 13:29:09] datibbaw@php.net
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)
------------------------------------------------------------------------
[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.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=42608
--
Edit this bug report at https://bugs.php.net/bug.php?id=42608&edit=1