Skip to content

Commit ed8d1ba

Browse files
committed
Fixed bug #69723 (Passing parameters by reference and array_column)
1 parent 50e08d6 commit ed8d1ba

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,8 @@
209209
required_num_args). (Julien)
210210

211211
- Standard:
212+
. Fixed bug #69723 (Passing parameters by reference and array_column).
213+
(Laruence)
212214
. Fixed bug #69523 (Cookie name cannot be empty). (Christoph M. Becker)
213215
. Fixed bug #69325 (php_copy_file_ex does not pass the argument).
214216
(imbolk at gmail dot com)

ext/standard/array.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3061,6 +3061,7 @@ PHP_FUNCTION(array_column)
30613061

30623062
array_init(return_value);
30633063
ZEND_HASH_FOREACH_VAL(arr_hash, data) {
3064+
ZVAL_DEREF(data);
30643065
if (Z_TYPE_P(data) != IS_ARRAY) {
30653066
/* Skip elemens which are not sub-arrays */
30663067
continue;
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
--TEST--
2+
Bug #69723 (Passing parameters by reference and array_column)
3+
--FILE--
4+
<?php
5+
function byReference( & $array){
6+
foreach($array as &$item){
7+
$item['nanana'] = 'batman';
8+
$item['superhero'] = 'robin';
9+
}
10+
}
11+
12+
$array = [
13+
[
14+
'superhero'=> 'superman',
15+
'nanana' => 'no nana'
16+
],
17+
[
18+
'superhero'=> 'acuaman',
19+
'nanana' => 'no nana'
20+
],
21+
22+
];
23+
24+
var_dump(array_column($array, 'superhero'));
25+
byReference($array);
26+
var_dump(array_column($array, 'superhero'));
27+
?>
28+
--EXPECT--
29+
array(2) {
30+
[0]=>
31+
string(8) "superman"
32+
[1]=>
33+
string(7) "acuaman"
34+
}
35+
array(2) {
36+
[0]=>
37+
string(5) "robin"
38+
[1]=>
39+
string(5) "robin"
40+
}

0 commit comments

Comments
 (0)