php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79376 Clone is enforcing copy-on-write on some properties in large app
Submitted: 2020-03-13 00:30 UTC Modified: 2020-03-13 00:59 UTC
From: michael dot vorisek at email dot cz Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 7.4.3 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: michael dot vorisek at email dot cz
New email:
PHP Version: OS:

 

 [2020-03-13 00:30 UTC] michael dot vorisek at email dot cz
Description:
------------
After tens of hours I have isolated an issue where setting one property sets the same property of the same class of different instance (verified by objects hashes).

I finally managed to fix the issue by the following code:

    public function __clone()
    {
        $elems = $this->elements;
        unset($this->elements);
        $this->elements = $elems;
        ...
}

I was not able to isolate this issue to short test code. Please confirm, that the following code is normally never needed if the "elements" property is an array and please check the source of PHP briefly for this issue. I have full access to the server so I can test anything.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-03-13 00:47 UTC] levim@php.net
-Status: Open +Status: Feedback
 [2020-03-13 00:47 UTC] levim@php.net
Is the object in question using inheritance, and if so is the parent an internal class?
 [2020-03-13 00:47 UTC] requinix@php.net
Sounds like elements is/was a reference.
 [2020-03-13 00:58 UTC] michael dot vorisek at email dot cz
Delete this
 [2020-03-13 00:59 UTC] requinix@php.net
-Status: Feedback +Status: Not a bug
 [2020-03-13 00:59 UTC] requinix@php.net
.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 26 16:01:29 2024 UTC