]> granicus.if.org Git - php/commitdiff
Fix array_keys() on $GLOBALS
authorNikita Popov <nikic@php.net>
Thu, 16 Oct 2014 12:44:35 +0000 (14:44 +0200)
committerNikita Popov <nikic@php.net>
Thu, 16 Oct 2014 12:44:35 +0000 (14:44 +0200)
ext/standard/array.c
ext/standard/tests/array/array_keys_on_GLOBALS.phpt [new file with mode: 0644]

index 7b49b2fd131d672ea4e74b594a41750b389fcfe2..7d8e4d0efe515b81a36f523c91e1f00a4a37a7bb 100644 (file)
@@ -2597,7 +2597,7 @@ PHP_FUNCTION(array_keys)
        add_key = 1;
 
        /* Go through input array and add keys to the return array */
-       ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(input), num_idx, str_idx, entry) {
+       ZEND_HASH_FOREACH_KEY_VAL_IND(Z_ARRVAL_P(input), num_idx, str_idx, entry) {
                if (search_value != NULL) {
                        is_equal_func(&res, search_value, entry TSRMLS_CC);
                        add_key = zval_is_true(&res);
diff --git a/ext/standard/tests/array/array_keys_on_GLOBALS.phpt b/ext/standard/tests/array/array_keys_on_GLOBALS.phpt
new file mode 100644 (file)
index 0000000..1d14ff4
--- /dev/null
@@ -0,0 +1,12 @@
+--TEST--
+Using array_keys() on $GLOBALS
+--FILE--
+<?php
+
+$foo = 'bar';
+unset($foo);
+var_dump(in_array('foo', array_keys($GLOBALS)));
+
+?>
+--EXPECT--
+bool(false)