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

From: Date: Sat, 22 Oct 2016 06:54:00 +0000
Subject: Bug #73350 [Ver->Csd]: Exception::__toString() cause circular references
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-204965@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: laruence@php.net Reported by: iceberg dot young at gmail dot com Summary: Exception::__toString() cause circular references -Status: Verified +Status: Closed 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: Automatic comment on behalf of laruence@gmail.com Revision: http://git.php.net/?p=php-src.git;a=commit;h=eca84946a4e7269d59ea2d79b5f42117de89ae74 Log: Fixed bug #73350 (Exception::__toString() cause circular references) Previous Comments: ------------------------------------------------------------------------ [2016-10-19 16:54:06] cmb@php.net Confirmed: <https://3v4l.org/F49vv> vs. <https://3v4l.org/Lgvq6>. ------------------------------------------------------------------------ [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 (#204965) next »