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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
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: Mon Jun 17 11:01:31 2024 UTC