]> granicus.if.org Git - php/commitdiff
Fixed bug #35022, #35019 (Regression in the behavior of key/current
authorIlia Alshanetsky <iliaa@php.net>
Sun, 30 Oct 2005 18:03:30 +0000 (18:03 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Sun, 30 Oct 2005 18:03:30 +0000 (18:03 +0000)
functions).

NEWS
ext/standard/basic_functions.c
ext/standard/tests/array/bug35022.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index a1dc4d13c31e245ac8e0bcebf27142820dafa969..098e41c7cad1b88f638468bd0d6415c7085ded82 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,8 @@
 PHP                                                                        NEWS
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 ?? Nov 2005, PHP 5.1
+- Fixed bug #35022, #35019 (Regression in the behavior of key/current 
+  functions). (Ilia)
 - Fixed bug #35014 (array_product() always returns 0). (Ilia)
 
 28 Oct 2005, PHP 5.1 Release Candidate 4
index d7ad276661c4b7750956f0cd6a7de2ed1d5e1b05..3c33779602c7604fd21b4d477b7bc927f1e1886a 100644 (file)
@@ -756,8 +756,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 (file)
index 0000000..e3f5386
--- /dev/null
@@ -0,0 +1,21 @@
+--TEST--
+Bug #35022 (Regression in the behavior of key/current functions)
+--FILE--
+<?php
+$state = array("one" => 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)