Bug #73350 [Opn->Ver]: Exception::__toString() cause circular references

From: Date: Wed, 19 Oct 2016 16:54:06 +0000
Subject: Bug #73350 [Opn->Ver]: Exception::__toString() cause circular references
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-204923@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=73350&edit=1 ID: 73350 Updated by: cmb@php.net Reported by: iceberg dot young at gmail dot com Summary: Exception::__toString() cause circular references -Status: Open +Status: Verified Type: Bug Package: *Programming Data Structures Operating System: CentOS 6/7; openSUSE Leap PHP Version: 7.0.12 Block user comment: N Private report: N New Comment: Confirmed: <https://3v4l.org/F49vv> vs. <https://3v4l.org/Lgvq6>. Previous Comments: ------------------------------------------------------------------------ [2016-10-19 15:01:59] iceberg dot young at gmail dot com 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 this bug report at https://bugs.php.net/bug.php?id=73350&edit=1

« previous php.bugs (#204923) next »