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:
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
Reference in New Issue
Block a user