Skip to content

Commit c96b975

Browse files
authored
filter_input_array - Implement solution 2 of GH-13805 (#13804)
1 parent 9a4847a commit c96b975

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

ext/filter/filter.c

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -690,29 +690,13 @@ PHP_FUNCTION(filter_input_array)
690690
}
691691

692692
array_input = php_filter_get_storage(fetch_from);
693+
693694
if (EG(exception)) {
694695
RETURN_THROWS();
695696
}
696697

697698
if (!array_input) {
698-
zend_long filter_flags = 0;
699-
zval *option;
700-
if (op_long) {
701-
filter_flags = op_long;
702-
} else if (op_ht && (option = zend_hash_str_find(op_ht, "flags", sizeof("flags") - 1)) != NULL) {
703-
filter_flags = zval_get_long(option);
704-
}
705-
706-
/* The FILTER_NULL_ON_FAILURE flag inverts the usual return values of
707-
* the function: normally when validation fails false is returned, and
708-
* when the input value doesn't exist NULL is returned. With the flag
709-
* set, NULL and false should be returned, respectively. Ergo, although
710-
* the code below looks incorrect, it's actually right. */
711-
if (filter_flags & FILTER_NULL_ON_FAILURE) {
712-
RETURN_FALSE;
713-
} else {
714-
RETURN_NULL();
715-
}
699+
RETURN_NULL();
716700
}
717701

718702
php_filter_array_handler(array_input, op_ht, op_long, return_value, add_empty);
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--TEST--
2+
filter_input_array: test FILTER_NULL_ON_FAILURE option does not affect general result on empty input
3+
--EXTENSIONS--
4+
filter
5+
--FILE--
6+
<?php
7+
$args = [
8+
"c" => [
9+
"flags" => FILTER_NULL_ON_FAILURE,
10+
]
11+
];
12+
13+
var_dump(filter_input_array(INPUT_GET, $args, true));
14+
?>
15+
--EXPECT--
16+
NULL

0 commit comments

Comments
 (0)