|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2016-05-17 19:07 UTC] bukka@php.net
-Assigned To:
+Assigned To: bukka
[2016-05-17 19:07 UTC] bukka@php.net
[2016-08-29 14:01 UTC] bukka@php.net
[2016-08-29 14:01 UTC] bukka@php.net
-Status: Assigned
+Status: Closed
[2016-08-29 14:03 UTC] bukka@php.net
[2016-08-29 14:12 UTC] bukka@php.net
[2016-10-17 10:09 UTC] bwoebi@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Nov 04 18:00:01 2025 UTC |
Description: ------------ When calling json_encode on an array of classes implementing JsonSerializable and all of the classes throw an exception, the original exception appears on the end of an exception chain that is equal to the length of the array + 1. Test script: --------------- <?php class MyClass implements JsonSerializable { public function jsonSerialize() { throw new Exception('Not implemented!'); } } $classes = []; for($i = 0; $i < 5; $i++) { $classes[] = new MyClass(); } try { json_encode($classes); } catch(Exception $e) { do { printf("%s (%d) [%s]\n", $e->getMessage(), $e->getCode(), get_class($e)); } while($e = $e->getPrevious()); } Expected result: ---------------- Failed calling MyClass::jsonSerialize() (0) [Exception] Not implemented! (0) [Exception] Actual result: -------------- Failed calling MyClass::jsonSerialize() (0) [Exception] Failed calling MyClass::jsonSerialize() (0) [Exception] Failed calling MyClass::jsonSerialize() (0) [Exception] Failed calling MyClass::jsonSerialize() (0) [Exception] Failed calling MyClass::jsonSerialize() (0) [Exception] Not implemented! (0) [Exception]