Bug #71336 [Opn->Csd]: Wrong is_ref on properties as exposed via get_object_vars()
| From: | laruence@php.net | Date: | Wed, 13 Jan 2016 09:38:47 +0000 |
| Subject: | Bug #71336 [Opn->Csd]: Wrong is_ref on properties as exposed via get_object_vars() | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-198620@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=71336&edit=1
ID: 71336
Updated by: laruence@php.net
Reported by: nicolas dot grekas+php at gmail dot com
Summary: Wrong is_ref on properties as exposed via
get_object_vars()
-Status: Open
+Status: Closed
Type: Bug
Package: Scripting Engine problem
PHP Version: 7.0.2
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of laruence@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=39f09507464bfa398c476a64d8b16b4061a3faec
Log: Fixed bug #71336 (Wrong is_ref on properties as exposed via get_object_vars())
Previous Comments:
------------------------------------------------------------------------
[2016-01-11 13:27:29] nicolas dot grekas+php at gmail dot com
Description:
------------
When a property is used as a reference by e.g. using array_pop on it, its is_ref flag is persisted,
which turns the property into a reference, and breaks get_object_vars for example. See example
script
See also https://3v4l.org/dcPn6
Test script:
---------------
<?php
class foo
{
protected $bar = array('baz');
function bar()
{
array_pop($this->bar);
$vars = get_object_vars($this);
print_r($vars);
$this->bar[] = array('buz');
print_r($vars);
}
}
$f = new foo();
$f->bar();
Expected result:
----------------
Array
(
[bar] => Array
(
)
)
Array
(
[bar] => Array
(
)
)
Actual result:
--------------
Array
(
[bar] => Array
(
)
)
Array
(
[bar] => Array
(
[0] => Array
(
[0] => buz
)
)
)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=71336&edit=1