From 432dc527adcbc3bf4809f6315350300d42c16c52 Mon Sep 17 00:00:00 2001 From: Levi Morrison Date: Wed, 2 Sep 2015 18:23:26 -0600 Subject: [PATCH] Partially fix bug #67167 - Wrong return value... ...from FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE The remainer of the fix would require the filter functions to only convert to string when it makes sense for that particular filter. --- ext/filter/filter.c | 7 ++++++- ext/filter/tests/bug67167.01.phpt | 16 ++++++++++++++++ ext/filter/tests/bug67167.02.phpt | 20 ++++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 ext/filter/tests/bug67167.01.phpt create mode 100644 ext/filter/tests/bug67167.02.phpt diff --git a/ext/filter/filter.c b/ext/filter/filter.c index 6f8a7a5f8b..e29a36ab71 100644 --- a/ext/filter/filter.c +++ b/ext/filter/filter.c @@ -389,7 +389,12 @@ static void php_zval_filter(zval *value, zend_long filter, zend_long flags, zval ce = Z_OBJCE_P(value); if (!ce->__tostring) { zval_ptr_dtor(value); - ZVAL_FALSE(value); + /* #67167: doesn't return null on failure for objects */ + if (flags & FILTER_NULL_ON_FAILURE) { + ZVAL_NULL(value); + } else { + ZVAL_FALSE(value); + } return; } } diff --git a/ext/filter/tests/bug67167.01.phpt b/ext/filter/tests/bug67167.01.phpt new file mode 100644 index 0000000000..09e84fd053 --- /dev/null +++ b/ext/filter/tests/bug67167.01.phpt @@ -0,0 +1,16 @@ +--TEST-- +Bug #67167: object with VALIDATE_BOOLEAN and NULL_ON_FAILURE + +--SKIPIF-- + + +--FILE-- + + +--FILE-- +