com php-src: Fixed bug #71660 (array_column behaves inc orrectly after foreach by reference): NEWS ext/ standard/array.c
ext/standard/tests/array/bug7166 0.phpt

From: Date: Thu, 25 Feb 2016 08:07:22 +0000
Subject: com php-src: Fixed bug #71660 (array_column behaves inc orrectly after foreach by reference): NEWS ext/ standard/array.c
ext/standard/tests/array/bug7166 0.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-91164@lists.php.net to get a copy of this message
Commit: c299b272c77b9bea4d6371a37a6d2b894f9729e8 Author: Xinchen Hui <laruence@gmail.com> Thu, 25 Feb 2016 16:07:22 +0800 Parents: fd561505f4142730684eacaba6f0ac5f293a8f0e Branches: PHP-7.0 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=c299b272c77b9bea4d6371a37a6d2b894f9729e8 Log: Fixed bug #71660 (array_column behaves incorrectly after foreach by reference) Bugs: https://bugs.php.net/71660 Changed paths: M NEWS M ext/standard/array.c A ext/standard/tests/array/bug71660.phpt Diff: diff --git a/NEWS b/NEWS index 27dfe73..a7c80bd 100644 --- a/NEWS +++ b/NEWS @@ -27,6 +27,10 @@ PHP NEWS . Fixed bug #71617 (private properties lost when unserializing ArrayObject). (Nikita) +- Standard: + . Fixed bug #71660 (array_column behaves incorrectly after foreach by + reference). (Laruence) + - Zip: . Update bundled libzip to 1.1.2. (Remi, Anatol) diff --git a/ext/standard/array.c b/ext/standard/array.c index 5add302..def7d7c 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -3498,6 +3498,10 @@ static inline zval *array_column_fetch_prop(zval *data, zval *name, zval *rv) } } + if (prop) { + ZVAL_DEREF(prop); + } + return prop; } diff --git a/ext/standard/tests/array/bug71660.phpt b/ext/standard/tests/array/bug71660.phpt new file mode 100644 index 0000000..c2d7192 --- /dev/null +++ b/ext/standard/tests/array/bug71660.phpt @@ -0,0 +1,18 @@ +--TEST-- +Bug #71660 (array_column behaves incorrectly after foreach by reference) +--FILE-- +<?php +$arr = array('id' => 12345, 'name' => 'sam'); +foreach ($arr as &$v) { + $v = $v; +} + +$arr = [$arr]; + +var_dump(array_column($arr, 'name', 'id')); +?> +--EXPECT-- +array(1) { + [12345]=> + string(3) "sam" +}

« previous php.cvs (#91164) next »