diff options
| author | Ilia Alshanetsky <iliaa@php.net> | 2010-12-12 19:27:04 +0000 |
|---|---|---|
| committer | Ilia Alshanetsky <iliaa@php.net> | 2010-12-12 19:27:04 +0000 |
| commit | 82287511ad70ad502755fd8b2564ae13114e4076 (patch) | |
| tree | d232f9fc4678dea6db157d68b6266bc7e1b59a75 | |
| parent | c1e9f628a046584e96bef0d05cff31075e4a9831 (diff) | |
| download | php-git-82287511ad70ad502755fd8b2564ae13114e4076.tar.gz | |
Fixed bug 48484 (array_product() always returns 0 for an empty array).
| -rw-r--r-- | NEWS | 3 | ||||
| -rw-r--r-- | ext/standard/array.c | 4 | ||||
| -rw-r--r-- | ext/standard/tests/array/bug35014.phpt | 2 | ||||
| -rw-r--r-- | ext/standard/tests/array/bug35014_64bit.phpt | 2 | ||||
| -rw-r--r-- | ext/standard/tests/array/bug48484.phpt | 16 |
5 files changed, 23 insertions, 4 deletions
@@ -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-- +<?php +var_dump(array_product(array())); +?> +--EXPECT-- +int(1) +--TEST-- +Bug 48484 (array_product() always returns 0 for an empty array) +--FILE-- +<?php +var_dump(array_product(array())); +?> +--EXPECT-- +int(1) |
