Bug #79291 [NEW]: Clone provokes a recursive reference

From: Date: Thu, 20 Feb 2020 12:47:11 +0000
Subject: Bug #79291 [NEW]: Clone provokes a recursive reference
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-225648@lists.php.net to get a copy of this message
From: ihorshein at gmail dot com Operating system: All PHP version: 7.2.28 Package: Scripting Engine problem Bug Type: Bug Bug description:Clone provokes a recursive reference Description: ------------ - The result of clone passed as an argument provokes a recursive reference. + The result of clone stored in the variable that is passed as an argument does not cause problems. Test script: --------------- function assign(&$r, $c){ $r = $c; } class A{ private $c; public function run(){ assign($this->c, clone $this); // this code generates actual result //$c = clone $this; //assign($this->c, $c); this code generates the expected result } } $o = new A(); $o->run(); var_dump($o); Expected result: ---------------- object(A)#27 (1) { ["c":"A":private]=> object(A)#13 (1) { ["c":"A":private]=> NULL } } Actual result: -------------- object(A)#21 (1) { ["c":"A":private]=> &object(A)#20 (1) { ["c":"A":private]=> *RECURSION* } } -- Edit bug report at https://bugs.php.net/bug.php?id=79291&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=79291&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=79291&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=79291&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=79291&r=needscript Try newer version: https://bugs.php.net/fix.php?id=79291&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=79291&r=support Expected behavior: https://bugs.php.net/fix.php?id=79291&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=79291&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=79291&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=79291&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=79291&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=79291&r=dst IIS Stability: https://bugs.php.net/fix.php?id=79291&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=79291&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=79291&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=79291&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=79291&r=mysqlcfg

« previous php.bugs (#225648) next »