jani Fri Nov 2 10:50:34 2007 UTC Modified files: /php-src/ext/standard array.c /php-src/ext/standard/tests/array bug41686.phpt Log: MFB52: Fixed bug #41686 http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.423&r2=1.424&diff_format=u Index: php-src/ext/standard/array.c diff -u php-src/ext/standard/array.c:1.423 php-src/ext/standard/array.c:1.424 --- php-src/ext/standard/array.c:1.423 Wed Oct 31 13:39:00 2007 +++ php-src/ext/standard/array.c Fri Nov 2 10:50:33 2007 @@ -21,7 +21,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: array.c,v 1.423 2007/10/31 13:39:00 jani Exp $ */ +/* $Id: array.c,v 1.424 2007/11/02 10:50:33 jani Exp $ */ #include "php.h" #include "php_ini.h" @@ -2309,7 +2309,7 @@ ulong num_key; HashPosition hpos; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "al|lb", &input, + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "al|l!b", &input, &offset, &length, &preserve_keys) == FAILURE) { return; } @@ -2317,8 +2317,8 @@ /* Get number of entries in the input hash */ num_in = zend_hash_num_elements(Z_ARRVAL_P(input)); - /* We want all entries from offset to the end if length is not passed */ - if (ZEND_NUM_ARGS() < 3) { + /* We want all entries from offset to the end if length is not passed or length is null */ + if (ZEND_NUM_ARGS() < 3 || length == NULL) { length = num_in; } http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/bug41686.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/standard/tests/array/bug41686.phpt diff -u /dev/null php-src/ext/standard/tests/array/bug41686.phpt:1.2 --- /dev/null Fri Nov 2 10:50:34 2007 +++ php-src/ext/standard/tests/array/bug41686.phpt Fri Nov 2 10:50:33 2007 @@ -0,0 +1,94 @@ +--TEST-- +Bug #41686 (Omitting length param in array_slice not possible) +--FILE-- +<?php +$a = array(1,2,3); +$b = array('a'=>1,'b'=>1,'c'=>2); + +var_dump( + array_slice($a, 1), + array_slice($a, 1, 2, TRUE), + array_slice($a, 1, NULL, TRUE), + array_slice($b, 1), + array_slice($b, 1, 2, TRUE), + array_slice($b, 1, NULL, TRUE) +); + +echo "Done\n"; +?> +--EXPECT-- +array(2) { + [0]=> + int(2) + [1]=> + int(3) +} +array(2) { + [1]=> + int(2) + [2]=> + int(3) +} +array(2) { + [1]=> + int(2) + [2]=> + int(3) +} +array(2) { + ["b"]=> + int(1) + ["c"]=> + int(2) +} +array(2) { + ["b"]=> + int(1) + ["c"]=> + int(2) +} +array(2) { + ["b"]=> + int(1) + ["c"]=> + int(2) +} +Done +--UEXPECT-- +array(2) { + [0]=> + int(2) + [1]=> + int(3) +} +array(2) { + [1]=> + int(2) + [2]=> + int(3) +} +array(2) { + [1]=> + int(2) + [2]=> + int(3) +} +array(2) { + [u"b"]=> + int(1) + [u"c"]=> + int(2) +} +array(2) { + [u"b"]=> + int(1) + [u"c"]=> + int(2) +} +array(2) { + [u"b"]=> + int(1) + [u"c"]=> + int(2) +} +Done
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php