Skip to content

Commit 8d2a9d8

Browse files
committed
Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2: Fixed bug #78759
2 parents 6d4965f + 5fa6dcd commit 8d2a9d8

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ PHP NEWS
66
. Fixed bug #78787 (Segfault with trait overriding inherited private shadow
77
property). (Nikita)
88

9+
- Standard:
10+
. Fixed bug #78759 (array_search in $GLOBALS). (Nikita)
11+
912
21 Nov 2019, PHP 7.3.12
1013

1114
- Core:

ext/standard/array.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1563,7 +1563,7 @@ static inline void php_search_array(INTERNAL_FUNCTION_PARAMETERS, int behavior)
15631563
ZEND_PARSE_PARAMETERS_END();
15641564

15651565
if (strict) {
1566-
ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(array), num_idx, str_idx, entry) {
1566+
ZEND_HASH_FOREACH_KEY_VAL_IND(Z_ARRVAL_P(array), num_idx, str_idx, entry) {
15671567
ZVAL_DEREF(entry);
15681568
if (fast_is_identical_function(value, entry)) {
15691569
if (behavior == 0) {
@@ -1580,7 +1580,7 @@ static inline void php_search_array(INTERNAL_FUNCTION_PARAMETERS, int behavior)
15801580
} ZEND_HASH_FOREACH_END();
15811581
} else {
15821582
if (Z_TYPE_P(value) == IS_LONG) {
1583-
ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(array), num_idx, str_idx, entry) {
1583+
ZEND_HASH_FOREACH_KEY_VAL_IND(Z_ARRVAL_P(array), num_idx, str_idx, entry) {
15841584
if (fast_equal_check_long(value, entry)) {
15851585
if (behavior == 0) {
15861586
RETURN_TRUE;
@@ -1595,7 +1595,7 @@ static inline void php_search_array(INTERNAL_FUNCTION_PARAMETERS, int behavior)
15951595
}
15961596
} ZEND_HASH_FOREACH_END();
15971597
} else if (Z_TYPE_P(value) == IS_STRING) {
1598-
ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(array), num_idx, str_idx, entry) {
1598+
ZEND_HASH_FOREACH_KEY_VAL_IND(Z_ARRVAL_P(array), num_idx, str_idx, entry) {
15991599
if (fast_equal_check_string(value, entry)) {
16001600
if (behavior == 0) {
16011601
RETURN_TRUE;
@@ -1610,7 +1610,7 @@ static inline void php_search_array(INTERNAL_FUNCTION_PARAMETERS, int behavior)
16101610
}
16111611
} ZEND_HASH_FOREACH_END();
16121612
} else {
1613-
ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(array), num_idx, str_idx, entry) {
1613+
ZEND_HASH_FOREACH_KEY_VAL_IND(Z_ARRVAL_P(array), num_idx, str_idx, entry) {
16141614
if (fast_equal_check_function(value, entry)) {
16151615
if (behavior == 0) {
16161616
RETURN_TRUE;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
Bug #78759: array_search in $GLOBALS
3+
--FILE--
4+
<?php
5+
6+
$a = 22;
7+
var_dump($GLOBALS["a"]); // int 22
8+
var_dump(array_search(22, $GLOBALS)); // false
9+
var_dump(array_search(22, $GLOBALS, true)); // false
10+
11+
?>
12+
--EXPECT--
13+
int(22)
14+
string(1) "a"
15+
string(1) "a"

0 commit comments

Comments
 (0)