Skip to content

Commit

Permalink
Merge branch 'PHP-7.0' into PHP-7.1
Browse files Browse the repository at this point in the history
  • Loading branch information
cmb69 committed Sep 9, 2016
2 parents e5ff8b2 + 1a30a7a commit e8e41aa
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ PHP NEWS
- Filter:
. Fixed bug #72972 (Bad filter for the flags FILTER_FLAG_NO_RES_RANGE and
FILTER_FLAG_NO_PRIV_RANGE). (julien)
. Fixed bug #73054 (default option ignored when object passed to int filter).
(cmb)

-GD:
. Fixed bug #67325 (imagetruecolortopalette: white is duplicated in palette).
Expand Down
3 changes: 2 additions & 1 deletion ext/filter/filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ static void php_zval_filter(zval *value, zend_long filter, zend_long flags, zval
} else {
ZVAL_FALSE(value);
}
return;
goto handle_default;
}
}

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

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

handle_default:
if (options && (Z_TYPE_P(options) == IS_ARRAY || Z_TYPE_P(options) == IS_OBJECT) &&
((flags & FILTER_NULL_ON_FAILURE && Z_TYPE_P(value) == IS_NULL) ||
(!(flags & FILTER_NULL_ON_FAILURE) && Z_TYPE_P(value) == IS_FALSE)) &&
Expand Down
23 changes: 23 additions & 0 deletions ext/filter/tests/bug73054.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
--TEST--
Bug #73054 (default option ignored when object passed to int filter)
--SKIPIF--
<?php
if (!extension_loaded('filter')) die('skip filter extension not available');
?>
--FILE--
<?php
var_dump(
filter_var(new stdClass, FILTER_VALIDATE_INT, [
'options' => ['default' => 2],
]),
filter_var(new stdClass, FILTER_VALIDATE_INT, [
'options' => ['default' => 2],
'flags' => FILTER_NULL_ON_FAILURE
])
);
?>
===DONE===
--EXPECT--
int(2)
int(2)
===DONE===

0 comments on commit e8e41aa

Please sign in to comment.