php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #68262 Broken reference across cloned objects
Submitted: 2014-10-18 23:17 UTC Modified: 2014-10-19 11:23 UTC
From: miloslav dot hula at gmail dot com Assigned: nikic (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: master-Git-2014-10-18 (Git) OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: miloslav dot hula at gmail dot com
New email:
PHP Version: OS:

 

 [2014-10-18 23:17 UTC] miloslav dot hula at gmail dot com
Description:
------------
Tested on fb85d0322d39d49f37e32df6f68c9769f2cce0e4 (17.10.2014)

Code works on PHP 5.0.0 - 5.6.2 (via http://3v4l.org).

Hard to describe. Test script below is extracted from failing library test.

Clonned object affects original one by reference in magic __get() method.

Test script:
---------------
class C
{
    public $p;

    public function &__get($n)
    {
        return $this->p;
    }
}


$first = new C;
$first->p = 'init';

$clone = clone $first;
$clone->p = $first->magic;

$clone = clone $first;
$clone->p = 'foo';

var_dump($first->v);


Expected result:
----------------
string(4) "init"

Actual result:
--------------
string(3) "foo"

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-10-19 11:23 UTC] nikic@php.net
Automatic comment on behalf of nikic
Revision: http://git.php.net/?p=php-src.git;a=commit;h=4b892439e61634b4bdcbf0bd54ef8577575875fd
Log: Fix bug #68262: Broken reference across cloned objects
 [2014-10-19 11:23 UTC] nikic@php.net
-Status: Open +Status: Closed
 [2014-10-19 11:23 UTC] nikic@php.net
-Summary: Broken reference across clonned objects +Summary: Broken reference across cloned objects -Assigned To: +Assigned To: nikic
 [2014-10-24 20:29 UTC] ab@php.net
Automatic comment on behalf of nikic
Revision: http://git.php.net/?p=php-src.git;a=commit;h=4b892439e61634b4bdcbf0bd54ef8577575875fd
Log: Fix bug #68262: Broken reference across cloned objects
 [2016-07-20 11:40 UTC] davey@php.net
Automatic comment on behalf of nikic
Revision: http://git.php.net/?p=php-src.git;a=commit;h=4b892439e61634b4bdcbf0bd54ef8577575875fd
Log: Fix bug #68262: Broken reference across cloned objects
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 18 22:01:31 2024 UTC