Handle INDIRECT values in array.
This commit is contained in:
Nikita Popov 2019-11-07 11:15:29 +01:00
parent d317e16e89
commit 5fa6dcd972
3 changed files with 21 additions and 4 deletions

2
NEWS
View File

@ -2,6 +2,8 @@ PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? 2019, PHP 7.2.26
- Standard:
. Fixed bug #78759 (array_search in $GLOBALS). (Nikita)
21 Nov 2019, PHP 7.2.25

View File

@ -1578,7 +1578,7 @@ static inline void php_search_array(INTERNAL_FUNCTION_PARAMETERS, int behavior)
ZEND_PARSE_PARAMETERS_END();
if (strict) {
ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(array), num_idx, str_idx, entry) {
ZEND_HASH_FOREACH_KEY_VAL_IND(Z_ARRVAL_P(array), num_idx, str_idx, entry) {
ZVAL_DEREF(entry);
if (fast_is_identical_function(value, entry)) {
if (behavior == 0) {
@ -1595,7 +1595,7 @@ static inline void php_search_array(INTERNAL_FUNCTION_PARAMETERS, int behavior)
} ZEND_HASH_FOREACH_END();
} else {
if (Z_TYPE_P(value) == IS_LONG) {
ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(array), num_idx, str_idx, entry) {
ZEND_HASH_FOREACH_KEY_VAL_IND(Z_ARRVAL_P(array), num_idx, str_idx, entry) {
if (fast_equal_check_long(value, entry)) {
if (behavior == 0) {
RETURN_TRUE;
@ -1610,7 +1610,7 @@ static inline void php_search_array(INTERNAL_FUNCTION_PARAMETERS, int behavior)
}
} ZEND_HASH_FOREACH_END();
} else if (Z_TYPE_P(value) == IS_STRING) {
ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(array), num_idx, str_idx, entry) {
ZEND_HASH_FOREACH_KEY_VAL_IND(Z_ARRVAL_P(array), num_idx, str_idx, entry) {
if (fast_equal_check_string(value, entry)) {
if (behavior == 0) {
RETURN_TRUE;
@ -1625,7 +1625,7 @@ static inline void php_search_array(INTERNAL_FUNCTION_PARAMETERS, int behavior)
}
} ZEND_HASH_FOREACH_END();
} else {
ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(array), num_idx, str_idx, entry) {
ZEND_HASH_FOREACH_KEY_VAL_IND(Z_ARRVAL_P(array), num_idx, str_idx, entry) {
if (fast_equal_check_function(value, entry)) {
if (behavior == 0) {
RETURN_TRUE;

View File

@ -0,0 +1,15 @@
--TEST--
Bug #78759: array_search in $GLOBALS
--FILE--
<?php
$a = 22;
var_dump($GLOBALS["a"]); // int 22
var_dump(array_search(22, $GLOBALS)); // false
var_dump(array_search(22, $GLOBALS, true)); // false
?>
--EXPECT--
int(22)
string(1) "a"
string(1) "a"