iliaa                                    Sun, 12 Dec 2010 19:27:04 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=306288

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

Bug: http://bugs.php.net/48484 (Verified) array_product(array()) returns 0 
instead of 1
      
Changed paths:
    U   php/php-src/branches/PHP_5_3/NEWS
    U   php/php-src/branches/PHP_5_3/ext/standard/array.c
    U   php/php-src/branches/PHP_5_3/ext/standard/tests/array/bug35014.phpt
    U   
php/php-src/branches/PHP_5_3/ext/standard/tests/array/bug35014_64bit.phpt
    A   php/php-src/branches/PHP_5_3/ext/standard/tests/array/bug48484.phpt
    U   php/php-src/trunk/ext/standard/array.c
    U   php/php-src/trunk/ext/standard/tests/array/bug35014.phpt
    U   php/php-src/trunk/ext/standard/tests/array/bug35014_64bit.phpt
    A   php/php-src/trunk/ext/standard/tests/array/bug48484.phpt

Modified: php/php-src/branches/PHP_5_3/NEWS
===================================================================
--- php/php-src/branches/PHP_5_3/NEWS   2010-12-12 19:06:27 UTC (rev 306287)
+++ php/php-src/branches/PHP_5_3/NEWS   2010-12-12 19:27:04 UTC (rev 306288)
@@ -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)

Modified: php/php-src/branches/PHP_5_3/ext/standard/array.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/standard/array.c   2010-12-12 19:06:27 UTC 
(rev 306287)
+++ php/php-src/branches/PHP_5_3/ext/standard/array.c   2010-12-12 19:27:04 UTC 
(rev 306288)
@@ -4048,10 +4048,10 @@
                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;

Modified: php/php-src/branches/PHP_5_3/ext/standard/tests/array/bug35014.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/standard/tests/array/bug35014.phpt 
2010-12-12 19:06:27 UTC (rev 306287)
+++ php/php-src/branches/PHP_5_3/ext/standard/tests/array/bug35014.phpt 
2010-12-12 19:27:04 UTC (rev 306288)
@@ -25,8 +25,8 @@
 --EXPECTF--
 Warning: array_product() expects parameter 1 to be array, string given in %s 
on line %d
 NULL
+int(1)
 int(0)
-int(0)
 int(3)
 int(9)
 float(1)

Modified: 
php/php-src/branches/PHP_5_3/ext/standard/tests/array/bug35014_64bit.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/standard/tests/array/bug35014_64bit.phpt   
2010-12-12 19:06:27 UTC (rev 306287)
+++ php/php-src/branches/PHP_5_3/ext/standard/tests/array/bug35014_64bit.phpt   
2010-12-12 19:27:04 UTC (rev 306288)
@@ -25,8 +25,8 @@
 --EXPECTF--
 Warning: array_product() expects parameter 1 to be array, string given in %s 
on line %d
 NULL
+int(1)
 int(0)
-int(0)
 int(3)
 int(9)
 float(1)

Added: php/php-src/branches/PHP_5_3/ext/standard/tests/array/bug48484.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/standard/tests/array/bug48484.phpt         
                (rev 0)
+++ php/php-src/branches/PHP_5_3/ext/standard/tests/array/bug48484.phpt 
2010-12-12 19:27:04 UTC (rev 306288)
@@ -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)

Modified: php/php-src/trunk/ext/standard/array.c
===================================================================
--- php/php-src/trunk/ext/standard/array.c      2010-12-12 19:06:27 UTC (rev 
306287)
+++ php/php-src/trunk/ext/standard/array.c      2010-12-12 19:27:04 UTC (rev 
306288)
@@ -4052,10 +4052,10 @@
                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;

Modified: php/php-src/trunk/ext/standard/tests/array/bug35014.phpt
===================================================================
--- php/php-src/trunk/ext/standard/tests/array/bug35014.phpt    2010-12-12 
19:06:27 UTC (rev 306287)
+++ php/php-src/trunk/ext/standard/tests/array/bug35014.phpt    2010-12-12 
19:27:04 UTC (rev 306288)
@@ -25,8 +25,8 @@
 --EXPECTF--
 Warning: array_product() expects parameter 1 to be array, string given in %s 
on line %d
 NULL
+int(1)
 int(0)
-int(0)
 int(3)
 int(9)
 float(1)

Modified: php/php-src/trunk/ext/standard/tests/array/bug35014_64bit.phpt
===================================================================
--- php/php-src/trunk/ext/standard/tests/array/bug35014_64bit.phpt      
2010-12-12 19:06:27 UTC (rev 306287)
+++ php/php-src/trunk/ext/standard/tests/array/bug35014_64bit.phpt      
2010-12-12 19:27:04 UTC (rev 306288)
@@ -25,8 +25,8 @@
 --EXPECTF--
 Warning: array_product() expects parameter 1 to be array, string given in %s 
on line %d
 NULL
+int(1)
 int(0)
-int(0)
 int(3)
 int(9)
 float(1)

Added: php/php-src/trunk/ext/standard/tests/array/bug48484.phpt
===================================================================
--- php/php-src/trunk/ext/standard/tests/array/bug48484.phpt                    
        (rev 0)
+++ php/php-src/trunk/ext/standard/tests/array/bug48484.phpt    2010-12-12 
19:27:04 UTC (rev 306288)
@@ -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)

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to