php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71336 Wrong is_ref on properties as exposed via get_object_vars()
Submitted: 2016-01-11 13:27 UTC Modified: -
From: nicolas dot grekas+php at gmail dot com Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 7.0.2 OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: nicolas dot grekas+php at gmail dot com
New email:
PHP Version: OS:

 

 [2016-01-11 13:27 UTC] 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
                )

        )

)


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-01-13 09:38 UTC] laruence@php.net
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())
 [2016-01-13 09:38 UTC] laruence@php.net
-Status: Open +Status: Closed
 [2016-07-20 11:34 UTC] davey@php.net
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())
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Oct 06 13:01:27 2024 UTC