From: Ilia Alshanetsky Date: Sun, 30 Oct 2005 18:04:20 +0000 (+0000) Subject: MFB51: Fixed bug #35022, #35019 (Regression in the behavior of key/current X-Git-Tag: RELEASE_2_0_1~104 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=61c8e857e491a209062f8d2e054647f3c610435a;p=php MFB51: Fixed bug #35022, #35019 (Regression in the behavior of key/current functions). --- diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 738cd7c203..8f0eb720ff 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -760,8 +760,8 @@ function_entry basic_functions[] = { PHP_FE(prev, first_arg_force_ref) PHP_FE(next, first_arg_force_ref) PHP_FE(reset, first_arg_force_ref) - PHP_FE(current, NULL) - PHP_FE(key, NULL) + PHP_FE(current, all_args_prefer_ref) + PHP_FE(key, all_args_prefer_ref) PHP_FE(min, NULL) PHP_FE(max, NULL) PHP_FE(in_array, NULL) diff --git a/ext/standard/tests/array/bug35022.phpt b/ext/standard/tests/array/bug35022.phpt new file mode 100644 index 0000000000..e3f5386482 --- /dev/null +++ b/ext/standard/tests/array/bug35022.phpt @@ -0,0 +1,21 @@ +--TEST-- +Bug #35022 (Regression in the behavior of key/current functions) +--FILE-- + 1, "two" => 2, "three" => 3); +function foo( &$state ) { + $contentDict = end( $state ); + for ( $contentDict = end( $state ); $contentDict !== false; $contentDict = prev( $state ) ) { + echo key($state) . " => " . current($state) . "\n"; + } +} +foo($state); +reset($state); +var_dump( key($state), current($state) ); +?> +--EXPECT-- +three => 3 +two => 2 +one => 1 +string(3) "one" +int(1)