From:             exaton at free dot fr
Operating system: WinXP SP2, Debian
PHP version:      5.2.1
PHP Bug Type:     Filter related
Bug description:  filter_var_aray() fails with a "common" filter

Description:
------------
[Tested on Windows XP SP2 / Apache 2.0.55 and on a Debian with kernel
2.6.16 / Apache 2.0.54 / PHP having the Suhosin-Patch applied].

Hello,

While reading http://phpro.org/tutorials/Filtering-Data-with-PHP.html, a
tutorial on using the new PHP Filter extension, I came across a simple test
case that fails unexpectedly.

$a = array(10, "109", "", "-1234", "some text", "asdf234asdfgs",
array());
var_dump(filter_var_array($a, FILTER_VALIDATE_INT));

Produces bool(false). I would have expected it to produce the same result
at :

var_dump(filter_var($a, FILTER_VALIDATE_INT, array(
        'flags' => FILTER_REQUIRE_ARRAY
)));

which displays array(7) { [0]=>  int(10) [1]=>  int(109) [2]=> 
bool(false) [3]=>  int(-1234) [4]=>  bool(false) [5]=>  bool(false) [6]=> 
array(0) { } } (int values for valid int entries, bool(false) for invalid
entries, as shown in the tutorial).

The manual entry for filter_var_array() indicates, regarding the second
parameter : "This parameter can be also an integer holding a filter
constant. Then all values in the input array are filtered by this
filter.".

I looked at the code of ext/filter in CVS and saw that this behavior seems
to be applied, boiling everything down to a single function. I could not
follow the code precisely enough (for lack of experience with  PHP
internals) to locate a significant divergence, however.

On another note, the manual entry for filter_var_array() provides a code
sample containing some constants which do not appear on the manual entry
for the Filter extension ; namely, FILTER_FLAG_ARRAY and
FILTER_FLAG_SCALAR. In the manual entry for filter_input_array(), which
gives the same code sample, these constants have been changed to the
existing FILTER_REQUIRE_ARRAY and FILTER_REQUIRE_SCALAR.

Thanks in advance !


-- 
Edit bug report at http://bugs.php.net/?id=40947&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=40947&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=40947&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=40947&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=40947&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=40947&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=40947&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=40947&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=40947&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=40947&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=40947&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=40947&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=40947&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=40947&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=40947&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=40947&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=40947&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=40947&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=40947&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=40947&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=40947&r=mysqlcfg

Reply via email to