Bug #76366 [Opn->Ver]: References in sub-array for filtering breaks the filter

From: Date: Wed, 23 May 2018 10:06:00 +0000
Subject: Bug #76366 [Opn->Ver]: References in sub-array for filtering breaks the filter
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-215339@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=76366&edit=1 ID: 76366 Updated by: cmb@php.net Reported by: dirk dot gerigk at atraveo dot com Summary: References in sub-array for filtering breaks the filter -Status: Open +Status: Verified Type: Bug Package: Filter related Operating System: Ubuntu PHP Version: 7.0Git-2018-05-22 (snap) Block user comment: N Private report: N New Comment: Confirmed: <https://3v4l.org/83gXR> Previous Comments: ------------------------------------------------------------------------ [2018-05-22 14:03:51] dirk dot gerigk at atraveo dot com Description: ------------ When using an array for filter variables and one sub-array is (or has) an reference the filter will not filter. This happens in all versions PHP >= 7. In PHP 5.6 it works correct. It takes me a long time to figure out, that the reference in the array produces the wrong behavior. If you var_dump $args before using it all seems fine. Test script: --------------- #array to filter $data = ['foo' => 6]; #filter args $args = ['foo'=> ['filter' => FILTER_VALIDATE_INT,'flags' => FILTER_FORCE_ARRAY]]; $args['foo']['options']=[]; #create reference $options = &$args['foo']['options']; #set options $options['min_range']=1; $options['max_range']=5; #show the filter result print_r(filter_var_array($data,$args)); Expected result: ---------------- Array ( [foo] => Array ( [0] => ) ) Actual result: -------------- Array ( [foo] => Array ( [0] => 6 ) ) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=76366&edit=1

« previous php.bugs (#215339) next »