Skip to content

Commit 9c7ba79

Browse files
committed
Merge branch 'PHP-7.1'
2 parents 6baaa2b + e8e41aa commit 9c7ba79

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

ext/filter/filter.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ static void php_zval_filter(zval *value, zend_long filter, zend_long flags, zval
397397
} else {
398398
ZVAL_FALSE(value);
399399
}
400-
return;
400+
goto handle_default;
401401
}
402402
}
403403

@@ -406,6 +406,7 @@ static void php_zval_filter(zval *value, zend_long filter, zend_long flags, zval
406406

407407
filter_func.function(value, flags, options, charset);
408408

409+
handle_default:
409410
if (options && (Z_TYPE_P(options) == IS_ARRAY || Z_TYPE_P(options) == IS_OBJECT) &&
410411
((flags & FILTER_NULL_ON_FAILURE && Z_TYPE_P(value) == IS_NULL) ||
411412
(!(flags & FILTER_NULL_ON_FAILURE) && Z_TYPE_P(value) == IS_FALSE)) &&

ext/filter/tests/bug73054.phpt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--TEST--
2+
Bug #73054 (default option ignored when object passed to int filter)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('filter')) die('skip filter extension not available');
6+
?>
7+
--FILE--
8+
<?php
9+
var_dump(
10+
filter_var(new stdClass, FILTER_VALIDATE_INT, [
11+
'options' => ['default' => 2],
12+
]),
13+
filter_var(new stdClass, FILTER_VALIDATE_INT, [
14+
'options' => ['default' => 2],
15+
'flags' => FILTER_NULL_ON_FAILURE
16+
])
17+
);
18+
?>
19+
===DONE===
20+
--EXPECT--
21+
int(2)
22+
int(2)
23+
===DONE===

0 commit comments

Comments
 (0)