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
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: 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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Sat Jul 12 10:01:33 2025 UTC