mirror of
https://github.com/Seldaek/monolog.git
synced 2026-04-25 23:55:56 +03:00
[GH-ISSUE #1237] MongoDBFormatter can affect passed by reference arguments when writing trace to log #514
Labels
No labels
Bug
Documentation
Feature
Needs Work
Support
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/monolog#514
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @FloatingMaster on GitHub (Dec 7, 2018).
Original GitHub issue: https://github.com/Seldaek/monolog/issues/1237
Steps to reproduce
Error handler:
Next in MongoDBFormatter::formatArray we have
If there was any pass-by-reference arguments (e.g.
foo(MyObj &$obj)) the object by reference will be replaced by formatted array.Example:
Output:
@Seldaek commented on GitHub (Dec 11, 2018):
This probably should be fixed (or at least checked if they are affected) for all normalizers.
@juan-morales commented on GitHub (Oct 21, 2021):
But, in such a case, what is adviced to do here in order to "fix" this "issue"?
As far as I know , there is no reliable way to check if a variable is a reference in PHP, and "cloning just in case" is not an option.
Am I missing something here?
@Seldaek commented on GitHub (Oct 22, 2021):
It might just be about assigning things to a new array instead of the same to make sure we copy the stack trace and get rid of references.
I'm not sure either.. Doesn't seem like a super critical issue tbh, it's so unlikely to happen.
@FloatingMaster commented on GitHub (Oct 22, 2021):
We solved the issue by recursivly converting record to array of simple type fields. Objects are converted to array through bsonSerialize, jsonSerialize or reflections
@juan-morales commented on GitHub (Oct 22, 2021):
@FloatingMaster you applied that code on private code? Can we see it so we can better understand what was suppose to be done?