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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
33 + 15 = ?
Subscribe to this entry?

 
 [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: Mon Jun 17 14:01:31 2024 UTC