cvs: php-src / NEWS /ext/standard array.c /ext/standard/tests/array bug33940.phpt

From: Date: Wed, 10 Aug 2005 08:23:40 +0000
Subject: cvs: php-src / NEWS /ext/standard array.c /ext/standard/tests/array bug33940.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-33267@lists.php.net to get a copy of this message
dmitry Wed Aug 10 04:23:40 2005 EDT Modified files: /php-src NEWS /php-src/ext/standard array.c /php-src/ext/standard/tests/array bug33940.phpt Log: Fixed bug #33940 (array_map() fails to pass by reference when called recursively) http://cvs.php.net/diff.php/php-src/NEWS?r1=1.2033&r2=1.2034&ty=u Index: php-src/NEWS diff -u php-src/NEWS:1.2033 php-src/NEWS:1.2034 --- php-src/NEWS:1.2033 Wed Aug 10 03:43:14 2005 +++ php-src/NEWS Wed Aug 10 04:23:38 2005 @@ -29,6 +29,8 @@ (Jani) - Fixed bug #33958 (duplicate cookies and magic_quotes=off may cause a crash). (Ilia) +- Fixed bug #33940 (array_map() fails to pass by reference when called + recursively). (Dmitry) - Fixed bug #33917 (number_format() output with > 1 char separators). (Jani) - Fixed bug #33904 (input array keys being escaped when magic quotes is off). (Ilia) http://cvs.php.net/diff.php/php-src/ext/standard/array.c?r1=1.309&r2=1.310&ty=u Index: php-src/ext/standard/array.c diff -u php-src/ext/standard/array.c:1.309 php-src/ext/standard/array.c:1.310 --- php-src/ext/standard/array.c:1.309 Wed Aug 10 03:43:15 2005 +++ php-src/ext/standard/array.c Wed Aug 10 04:23:39 2005 @@ -21,7 +21,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: array.c,v 1.309 2005/08/10 07:43:15 dmitry Exp $ */ +/* $Id: array.c,v 1.310 2005/08/10 08:23:39 dmitry Exp $ */ #include "php.h" #include "php_ini.h" @@ -4252,6 +4252,7 @@ efree(array_pos); return; } + SEPARATE_ZVAL_IF_NOT_REF(pargs[i]); args[i] = *pargs[i]; array_len[i] = zend_hash_num_elements(Z_ARRVAL_PP(pargs[i])); if (array_len[i] > maxlen) { http://cvs.php.net/diff.php/php-src/ext/standard/tests/array/bug33940.phpt?r1=1.1&r2=1.2&ty=u Index: php-src/ext/standard/tests/array/bug33940.phpt diff -u /dev/null php-src/ext/standard/tests/array/bug33940.phpt:1.2 --- /dev/null Wed Aug 10 04:23:40 2005 +++ php-src/ext/standard/tests/array/bug33940.phpt Wed Aug 10 04:23:39 2005 @@ -0,0 +1,62 @@ +--TEST-- +Bug #33940 array_map() fails to pass by reference when called recursively +--INI-- +error_reporting=4095 +--FILE-- +<?php +function ref_map(&$item) { + if(!is_array($item)) { + $item = 1; + return 2; + } else { + $ret = array_map('ref_map', &$item); + return $ret; + } +} + +$a = array(array(0), 0); +$ret = array_map('ref_map', $a); +echo 'Array: '; print_r($a); +echo 'Return: '; print_r($ret); +$a = array(array(0), 0); +$ret = array_map('ref_map', &$a); +echo 'Array: '; print_r($a); +echo 'Return: '; print_r($ret); +?> +--EXPECT-- +Array: Array +( + [0] => Array + ( + [0] => 0 + ) + + [1] => 0 +) +Return: Array +( + [0] => Array + ( + [0] => 2 + ) + + [1] => 2 +) +Array: Array +( + [0] => Array + ( + [0] => 1 + ) + + [1] => 1 +) +Return: Array +( + [0] => Array + ( + [0] => 2 + ) + + [1] => 2 +)

« previous php.cvs (#33267) next »