Skip to content

Commit bc28ed6

Browse files
committed
Merge branch 'master' of git.php.net:php-src
* 'master' of git.php.net:php-src: Remove wrong commit committed by accident Fixed bug #69167 (call_user_func does not support references anymore) Fixed #69166 (Assigning array_values() to array does not reset key counter)
2 parents f97251a + aa63449 commit bc28ed6

File tree

4 files changed

+44
-4
lines changed

4 files changed

+44
-4
lines changed

Zend/tests/bug69167.phpt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
Bug #69167 (call_user_func does not support references anymore)
3+
--FILE--
4+
<?php
5+
function l($m) {
6+
echo $m . "\n";
7+
}
8+
9+
$cb = 'l';
10+
call_user_func($cb, 'hi');
11+
12+
$cb2 = &$cb;
13+
call_user_func($cb2, 'hi2');
14+
?>
15+
--EXPECT--
16+
hi
17+
hi2

Zend/zend_API.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3017,6 +3017,7 @@ ZEND_API zend_bool zend_is_callable_ex(zval *callable, zend_object *object, uint
30173017
return 0;
30183018
}
30193019

3020+
again:
30203021
switch (Z_TYPE_P(callable)) {
30213022
case IS_STRING:
30223023
if (object) {
@@ -3160,7 +3161,6 @@ ZEND_API zend_bool zend_is_callable_ex(zval *callable, zend_object *object, uint
31603161
}
31613162
}
31623163
return 0;
3163-
31643164
case IS_OBJECT:
31653165
if (Z_OBJ_HANDLER_P(callable, get_closure) && Z_OBJ_HANDLER_P(callable, get_closure)(callable, &fcc->calling_scope, &fcc->function_handler, &fcc->object) == SUCCESS) {
31663166
fcc->called_scope = fcc->calling_scope;
@@ -3173,8 +3173,14 @@ ZEND_API zend_bool zend_is_callable_ex(zval *callable, zend_object *object, uint
31733173
}
31743174
return 1;
31753175
}
3176-
/* break missing intentionally */
3177-
3176+
if (callable_name) {
3177+
*callable_name = zval_get_string(callable);
3178+
}
3179+
if (error) zend_spprintf(error, 0, "no array or string given");
3180+
return 0;
3181+
case IS_REFERENCE:
3182+
callable = Z_REFVAL_P(callable);
3183+
goto again;
31783184
default:
31793185
if (callable_name) {
31803186
*callable_name = zval_get_string(callable);

Zend/zend_hash.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ static zend_always_inline void *zend_hash_get_current_data_ptr_ex(HashTable *ht,
795795
#define ZEND_HASH_FILL_END() \
796796
__fill_ht->nNumUsed = __fill_idx; \
797797
__fill_ht->nNumOfElements = __fill_idx; \
798-
__fill_ht->nNextFreeElement = __fill_idx + 1; \
798+
__fill_ht->nNextFreeElement = __fill_idx; \
799799
__fill_ht->nInternalPointer = 0; \
800800
} while (0)
801801

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
Fixed #69166 (Assigning array_values() to array does not reset key counter)
3+
--FILE--
4+
<?php
5+
6+
$array = [0];
7+
$ar = array_values($array);
8+
$ar[] = 1;
9+
var_dump($ar);
10+
?>
11+
--EXPECT--
12+
array(2) {
13+
[0]=>
14+
int(0)
15+
[1]=>
16+
int(1)
17+
}

0 commit comments

Comments
 (0)