|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2020-03-13 00:59 UTC] requinix@php.net
-Status: Open
+Status: Not a bug
[2020-03-13 00:59 UTC] requinix@php.net
[2020-03-13 01:38 UTC] requinix@php.net
[2020-03-13 01:52 UTC] mvorisek at mvorisek dot cz
[2020-03-13 02:42 UTC] requinix@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 07 08:00:02 2026 UTC |
Description: ------------ Seems like a core bug presented in all PHP versions (5.4.0 - 7.4.3 tested). Please verify and fix asap. Test script: --------------- class A { public $elements = []; public function __construct() { $this->fields = &$this->elements; // this causes the issue } public function __clone() { // $elems = $this->elements; unset($this->elements); $this->elements = $elems; $this->fields = &$this->elements; // this is an immediate fix before fixed in PHP directly } } $x = new A(); $y = clone $x; $y->elements['hello'] = 'world'; print_r($x); print_r($y); Expected result: ---------------- A Object ( [elements] => Array ( ) [fields] => Array ( ) ) A Object ( [elements] => Array ( [hello] => world ) [fields] => Array ( [hello] => world ) ) Actual result: -------------- A Object ( [elements] => Array ( [hello] => world ) [fields] => Array ( [hello] => world ) ) A Object ( [elements] => Array ( [hello] => world ) [fields] => Array ( [hello] => world ) )