Skip to content

Commit

Permalink
Fixed bug #69723 (Passing parameters by reference and array_column)
Browse files Browse the repository at this point in the history
  • Loading branch information
laruence committed May 29, 2015
1 parent 50e08d6 commit ed8d1ba
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
2 changes: 2 additions & 0 deletions NEWS
Expand Up @@ -209,6 +209,8 @@
required_num_args). (Julien)

- Standard:
. Fixed bug #69723 (Passing parameters by reference and array_column).
(Laruence)
. Fixed bug #69523 (Cookie name cannot be empty). (Christoph M. Becker)
. Fixed bug #69325 (php_copy_file_ex does not pass the argument).
(imbolk at gmail dot com)
Expand Down
1 change: 1 addition & 0 deletions ext/standard/array.c
Expand Up @@ -3061,6 +3061,7 @@ PHP_FUNCTION(array_column)

array_init(return_value);
ZEND_HASH_FOREACH_VAL(arr_hash, data) {
ZVAL_DEREF(data);
if (Z_TYPE_P(data) != IS_ARRAY) {
/* Skip elemens which are not sub-arrays */
continue;
Expand Down
40 changes: 40 additions & 0 deletions ext/standard/tests/array/bug69723.phpt
@@ -0,0 +1,40 @@
--TEST--
Bug #69723 (Passing parameters by reference and array_column)
--FILE--
<?php
function byReference( & $array){
foreach($array as &$item){
$item['nanana'] = 'batman';
$item['superhero'] = 'robin';
}
}

$array = [
[
'superhero'=> 'superman',
'nanana' => 'no nana'
],
[
'superhero'=> 'acuaman',
'nanana' => 'no nana'
],

];

var_dump(array_column($array, 'superhero'));
byReference($array);
var_dump(array_column($array, 'superhero'));
?>
--EXPECT--
array(2) {
[0]=>
string(8) "superman"
[1]=>
string(7) "acuaman"
}
array(2) {
[0]=>
string(5) "robin"
[1]=>
string(5) "robin"
}

0 comments on commit ed8d1ba

Please sign in to comment.