fix: handle resources and closures in JSON exception responses#9788
fix: handle resources and closures in JSON exception responses#9788michalsn merged 2 commits intocodeigniter4:developfrom
Conversation
|
Where are private properties used? Did I get it wrong? What do you think about putting it in a separate Normalizer class? Because the same action is sometimes necessary for Response. Yes, in this case it is better to take care of the types earlier, but if you just return the object from the Formatter, it will also be a mistake. Besides, we have other XML formatter, |
If your class has private properties, they will appear in the
I don't really see the point. I don't think any of these should be exposed through our API. In such cases, I would expect an error to be raised to indicate the issue. And adding extra processing to every API response is not something I would like. |
neznaika0
left a comment
There was a problem hiding this comment.
Good. Important questions should be asked right away. When we look at PR a year later, it's hard to remember why this was done.
Well, true... but it usually happens to me after like 2 weeks 😅 |
|
Thank you everyone for the review! |
Description
This PR fixes JSON encoding failures when exception traces contain resources (like database connections), closures, or circular references in API responses.
Additionally, it updates the JSON response trace details to match those of traditional HTML-based error pages. Previously, the JSON traces were overly simplified because
json_encode()only serializes public object properties, ignoring private and protected ones.I tried to find out whether this simplified JSON trace was intentional, but couldn't find any clear reason for it.
Fixes #9786
Checklist: