From: Ilia Alshanetsky Date: Sun, 12 Dec 2010 19:27:04 +0000 (+0000) Subject: Fixed bug 48484 (array_product() always returns 0 for an empty array). X-Git-Tag: php-5.3.6RC1~241 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=82287511ad70ad502755fd8b2564ae13114e4076;p=php Fixed bug 48484 (array_product() always returns 0 for an empty array). --- diff --git a/NEWS b/NEWS index d4219c8e92..e0dc86a670 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,9 @@ . Indirect reference to $this fails to resolve if direct $this is never used in method. (Scott) +- Core: + . Bug 48484 (array_product() always returns 0 for an empty array). (Ilia) + - Filter extension: . Fixed bug #53150 (FILTER_FLAG_NO_RES_RANGE is missing some IP ranges). (Ilia) diff --git a/ext/standard/array.c b/ext/standard/array.c index 03ecd5c3ca..cdb6234937 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -4048,10 +4048,10 @@ PHP_FUNCTION(array_product) return; } + ZVAL_LONG(return_value, 1); if (!zend_hash_num_elements(Z_ARRVAL_P(input))) { - RETURN_LONG(0); + return; } - ZVAL_LONG(return_value, 1); for (zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(input), &pos); zend_hash_get_current_data_ex(Z_ARRVAL_P(input), (void **)&entry, &pos) == SUCCESS; diff --git a/ext/standard/tests/array/bug35014.phpt b/ext/standard/tests/array/bug35014.phpt index 3a6cf216ab..9250c03e10 100644 --- a/ext/standard/tests/array/bug35014.phpt +++ b/ext/standard/tests/array/bug35014.phpt @@ -25,7 +25,7 @@ foreach ($tests as $v) { --EXPECTF-- Warning: array_product() expects parameter 1 to be array, string given in %s on line %d NULL -int(0) +int(1) int(0) int(3) int(9) diff --git a/ext/standard/tests/array/bug35014_64bit.phpt b/ext/standard/tests/array/bug35014_64bit.phpt index 1c325b3fb0..efd791ac99 100644 --- a/ext/standard/tests/array/bug35014_64bit.phpt +++ b/ext/standard/tests/array/bug35014_64bit.phpt @@ -25,7 +25,7 @@ foreach ($tests as $v) { --EXPECTF-- Warning: array_product() expects parameter 1 to be array, string given in %s on line %d NULL -int(0) +int(1) int(0) int(3) int(9) diff --git a/ext/standard/tests/array/bug48484.phpt b/ext/standard/tests/array/bug48484.phpt new file mode 100644 index 0000000000..006c3cc981 --- /dev/null +++ b/ext/standard/tests/array/bug48484.phpt @@ -0,0 +1,16 @@ +--TEST-- +Bug 48484 (array_product() always returns 0 for an empty array) +--FILE-- + +--EXPECT-- +int(1) +--TEST-- +Bug 48484 (array_product() always returns 0 for an empty array) +--FILE-- + +--EXPECT-- +int(1)