]> granicus.if.org Git - php/commitdiff
Fixed bug 48484 (array_product() always returns 0 for an empty array).
authorIlia Alshanetsky <iliaa@php.net>
Sun, 12 Dec 2010 19:27:04 +0000 (19:27 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Sun, 12 Dec 2010 19:27:04 +0000 (19:27 +0000)
NEWS
ext/standard/array.c
ext/standard/tests/array/bug35014.phpt
ext/standard/tests/array/bug35014_64bit.phpt
ext/standard/tests/array/bug48484.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index d4219c8e92ccf5d6536fdeffacc8b01bf4c8634a..e0dc86a67011acbac3551cfc079ba24cc6864a07 100644 (file)
--- 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)
index 03ecd5c3ca811946017d85bb7d6e46c85672b9e8..cdb6234937d5e228e5929a4052e64e6349528c97 100644 (file)
@@ -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;
index 3a6cf216abc53053a08939b55a26b1a389545384..9250c03e1082690e8a2d3f2bcd47df681e1629bf 100644 (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)
index 1c325b3fb02be27ddaf2defc989c6adc07d248aa..efd791ac993909fb7cfacb3f958bc6f6cb440e2b 100644 (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)
diff --git a/ext/standard/tests/array/bug48484.phpt b/ext/standard/tests/array/bug48484.phpt
new file mode 100644 (file)
index 0000000..006c3cc
--- /dev/null
@@ -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)