Skip to content

Commit 5a538e1

Browse files
committed
Merge branch 'PHP-7.0'
2 parents b5d01ab + a879215 commit 5a538e1

File tree

3 files changed

+51
-48
lines changed

3 files changed

+51
-48
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
--TEST--
2+
call_user_func_array() passes value to prefer-ref arg if element wasn't a reference
3+
--FILE--
4+
<?php
5+
6+
namespace {
7+
call_user_func_array('array_multisort', [[3, 2, 1]]);
8+
9+
$args = [[3, 2, 1]];
10+
call_user_func_array('array_multisort', $args);
11+
var_dump($args);
12+
unset($args);
13+
}
14+
15+
namespace Foo {
16+
call_user_func_array('array_multisort', [[3, 2, 1]]);
17+
18+
$args = [[3, 2, 1]];
19+
call_user_func_array('array_multisort', $args);
20+
var_dump($args);
21+
unset($args);
22+
}
23+
24+
?>
25+
--EXPECT--
26+
array(1) {
27+
[0]=>
28+
array(3) {
29+
[0]=>
30+
int(3)
31+
[1]=>
32+
int(2)
33+
[2]=>
34+
int(1)
35+
}
36+
}
37+
array(1) {
38+
[0]=>
39+
array(3) {
40+
[0]=>
41+
int(3)
42+
[1]=>
43+
int(2)
44+
[2]=>
45+
int(1)
46+
}
47+
}

Zend/zend_vm_def.h

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4566,22 +4566,6 @@ ZEND_VM_C_LABEL(send_array):
45664566
ht = Z_ARRVAL_P(args);
45674567
zend_vm_stack_extend_call_frame(&EX(call), 0, zend_hash_num_elements(ht));
45684568

4569-
if (OP1_TYPE != IS_CONST && OP1_TYPE != IS_TMP_VAR && Z_IMMUTABLE_P(args)) {
4570-
int separate = 0;
4571-
4572-
/* check if any of arguments are going to be passed by reference */
4573-
for (arg_num = 0; arg_num < zend_hash_num_elements(ht); arg_num++) {
4574-
if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->func, arg_num + 1)) {
4575-
separate = 1;
4576-
break;
4577-
}
4578-
}
4579-
if (separate) {
4580-
zval_copy_ctor(args);
4581-
ht = Z_ARRVAL_P(args);
4582-
}
4583-
}
4584-
45854569
arg_num = 1;
45864570
param = ZEND_CALL_ARG(EX(call), 1);
45874571
ZEND_HASH_FOREACH_VAL(ht, arg) {
@@ -4607,21 +4591,15 @@ ZEND_VM_C_LABEL(send_array):
46074591

46084592
break;
46094593
}
4610-
4611-
ZVAL_NEW_REF(arg, arg);
46124594
}
4613-
Z_ADDREF_P(arg);
4614-
} else{
4595+
} else {
46154596
if (Z_ISREF_P(arg) &&
46164597
!(EX(call)->func->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE)) {
46174598
/* don't separate references for __call */
46184599
arg = Z_REFVAL_P(arg);
46194600
}
4620-
if (Z_OPT_REFCOUNTED_P(arg)) {
4621-
Z_ADDREF_P(arg);
4622-
}
46234601
}
4624-
ZVAL_COPY_VALUE(param, arg);
4602+
ZVAL_COPY(param, arg);
46254603
ZEND_CALL_NUM_ARGS(EX(call))++;
46264604
arg_num++;
46274605
param++;

Zend/zend_vm_execute.h

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,22 +1440,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_ARRAY_SPEC_HANDLER(ZEND_O
14401440
ht = Z_ARRVAL_P(args);
14411441
zend_vm_stack_extend_call_frame(&EX(call), 0, zend_hash_num_elements(ht));
14421442

1443-
if (opline->op1_type != IS_CONST && opline->op1_type != IS_TMP_VAR && Z_IMMUTABLE_P(args)) {
1444-
int separate = 0;
1445-
1446-
/* check if any of arguments are going to be passed by reference */
1447-
for (arg_num = 0; arg_num < zend_hash_num_elements(ht); arg_num++) {
1448-
if (ARG_SHOULD_BE_SENT_BY_REF(EX(call)->func, arg_num + 1)) {
1449-
separate = 1;
1450-
break;
1451-
}
1452-
}
1453-
if (separate) {
1454-
zval_copy_ctor(args);
1455-
ht = Z_ARRVAL_P(args);
1456-
}
1457-
}
1458-
14591443
arg_num = 1;
14601444
param = ZEND_CALL_ARG(EX(call), 1);
14611445
ZEND_HASH_FOREACH_VAL(ht, arg) {
@@ -1481,21 +1465,15 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_SEND_ARRAY_SPEC_HANDLER(ZEND_O
14811465

14821466
break;
14831467
}
1484-
1485-
ZVAL_NEW_REF(arg, arg);
14861468
}
1487-
Z_ADDREF_P(arg);
1488-
} else{
1469+
} else {
14891470
if (Z_ISREF_P(arg) &&
14901471
!(EX(call)->func->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE)) {
14911472
/* don't separate references for __call */
14921473
arg = Z_REFVAL_P(arg);
14931474
}
1494-
if (Z_OPT_REFCOUNTED_P(arg)) {
1495-
Z_ADDREF_P(arg);
1496-
}
14971475
}
1498-
ZVAL_COPY_VALUE(param, arg);
1476+
ZVAL_COPY(param, arg);
14991477
ZEND_CALL_NUM_ARGS(EX(call))++;
15001478
arg_num++;
15011479
param++;

0 commit comments

Comments
 (0)