1
0
mirror of https://github.com/php/php-src.git synced 2026-04-28 10:43:30 +02:00

Fixed bug 48484 (array_product() always returns 0 for an empty array).

This commit is contained in:
Ilia Alshanetsky
2010-12-12 19:27:04 +00:00
parent c6bbf9ee57
commit 9696faa790
4 changed files with 13 additions and 5 deletions
+3 -3
View File
@@ -4052,10 +4052,10 @@ PHP_FUNCTION(array_product)
return;
}
if (!zend_hash_num_elements(Z_ARRVAL_P(input))) {
RETURN_LONG(0);
}
ZVAL_LONG(return_value, 1);
if (!zend_hash_num_elements(Z_ARRVAL_P(input))) {
return;
}
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;
+1 -1
View File
@@ -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)
+1 -1
View File
@@ -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)
+8
View File
@@ -0,0 +1,8 @@
--TEST--
Bug 48484 (array_product() always returns 0 for an empty array)
--FILE--
<?php
var_dump(array_product(array()));
?>
--EXPECT--
int(1)