Skip to content

Commit 57a385d

Browse files
committed
Merge branch 'PHP-7.4'
2 parents 1f800e2 + ea86a92 commit 57a385d

File tree

1 file changed

+30
-12
lines changed

1 file changed

+30
-12
lines changed

ext/standard/array.c

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1543,21 +1543,39 @@ static inline void php_search_array(INTERNAL_FUNCTION_PARAMETERS, int behavior)
15431543
ZEND_PARSE_PARAMETERS_END();
15441544

15451545
if (strict) {
1546-
ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(array), num_idx, str_idx, entry) {
1547-
ZVAL_DEREF(entry);
1548-
if (fast_is_identical_function(value, entry)) {
1549-
if (behavior == 0) {
1550-
RETURN_TRUE;
1551-
} else {
1552-
if (str_idx) {
1553-
RETVAL_STR_COPY(str_idx);
1546+
if (Z_TYPE_P(value) == IS_LONG) {
1547+
ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(array), num_idx, str_idx, entry) {
1548+
ZVAL_DEREF(entry);
1549+
if (Z_TYPE_P(entry) == IS_LONG && Z_LVAL_P(entry) == Z_LVAL_P(value)) {
1550+
if (behavior == 0) {
1551+
RETURN_TRUE;
15541552
} else {
1555-
RETVAL_LONG(num_idx);
1553+
if (str_idx) {
1554+
RETVAL_STR_COPY(str_idx);
1555+
} else {
1556+
RETVAL_LONG(num_idx);
1557+
}
1558+
return;
15561559
}
1557-
return;
15581560
}
1559-
}
1560-
} ZEND_HASH_FOREACH_END();
1561+
} ZEND_HASH_FOREACH_END();
1562+
} else {
1563+
ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(array), num_idx, str_idx, entry) {
1564+
ZVAL_DEREF(entry);
1565+
if (fast_is_identical_function(value, entry)) {
1566+
if (behavior == 0) {
1567+
RETURN_TRUE;
1568+
} else {
1569+
if (str_idx) {
1570+
RETVAL_STR_COPY(str_idx);
1571+
} else {
1572+
RETVAL_LONG(num_idx);
1573+
}
1574+
return;
1575+
}
1576+
}
1577+
} ZEND_HASH_FOREACH_END();
1578+
}
15611579
} else {
15621580
if (Z_TYPE_P(value) == IS_LONG) {
15631581
ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(array), num_idx, str_idx, entry) {

0 commit comments

Comments
 (0)