Bug #73350 [NEW]: Exception::__toString() cause circular references

From: Date: Wed, 19 Oct 2016 15:02:03 +0000
Subject: Bug #73350 [NEW]: Exception::__toString() cause circular references
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-204920@lists.php.net to get a copy of this message
From: iceberg dot young at gmail dot com Operating system: CentOS 6/7; openSUSE Leap PHP version: 7.0.12 Package: *Programming Data Structures Bug Type: Bug Bug description:Exception::__toString() cause circular references Description: ------------ Exception::__toString() method will cause circular references. And therefore breaks some *array* related functions. Version 7.0.11 is fine. Tested on CentOS 6/7 x64, packages from http://rpms.famillecollet.com/enterprise/{6,7}/php70/x86_64/repoview/ Tested on openSUSE Leap 42.1 x64, packages from http://download.opensuse.org/repositories/devel:/languages:/php/openSUSE_Leap_42.1/ Test script: --------------- <?php $e = new Exception(); // This line cause problem :( // Comment it to see the difference. (string) $e; // This line show the clue (PHP Warning: ...). var_export($e); // This line will be affected. var_export(json_encode([$e])); // But This line still OK. var_export(json_encode($e)); Expected result: ---------------- # var_export($e) Exception::__set_state(array( 'message' => '', 'string' => '', 'code' => 0, 'file' => 'demo.php', 'line' => 2, 'trace' => array ( ), 'previous' => NULL, )) # var_export(json_encode([$e])) '[{}]' # var_export(json_encode($e)) '{}' Actual result: -------------- # var_export($e) PHP Warning: var_export does not handle circular references in demo.php on line 9 NULL # var_export(json_encode([$e])) false # var_export(json_encode($e)) '{}' -- Edit bug report at https://bugs.php.net/bug.php?id=73350&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=73350&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=73350&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=73350&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=73350&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=73350&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=73350&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=73350&r=needscript Try newer version: https://bugs.php.net/fix.php?id=73350&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=73350&r=support Expected behavior: https://bugs.php.net/fix.php?id=73350&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=73350&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=73350&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=73350&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=73350&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=73350&r=dst IIS Stability: https://bugs.php.net/fix.php?id=73350&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=73350&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=73350&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=73350&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=73350&r=mysqlcfg

« previous php.bugs (#204920) next »