serializer icon indicating copy to clipboard operation
serializer copied to clipboard

Why is in the JsonSerializationVisitor.php, NotAcceptableException catched and not throw further.

Open baloraki opened this issue 2 years ago • 3 comments

| Question

Steps required to reproduce the problem

Serialize an object with some circular reference

Expected Result

Error CircularReferenceDetectedException from SerializationGraphNavigator::accept should not catched in JsonSerializationVisitor::visitProperty, to avoid endless loops.

Actual Result

The error will catched in JsonSerializationVisitor::visitProperty, which ends in a endles loop, when in the data circular references exist.

baloraki avatar Nov 09 '22 14:11 baloraki

Hello! Could you provide some more details, please? It looks like the mentioned example should be covered by BaseSerializationTest::testCircularReference().

scyzoryck avatar Nov 10 '22 18:11 scyzoryck

Hello, thanks for the response. The problem is that when the accept, in a visit( e.g. visitProperty), throws a CircularReferenceDetectedException, it will be caught with NotAcceptableException and it continues.

My expected outcome is simply that the error is not caught, as in my case it results in an infinite loop. image

My question is why this is so and what I could do to get out of potential endless loops.

baloraki avatar Nov 10 '22 19:11 baloraki

Is it possible to reproduce your use case with some unit test or code snippet? It looks like a bug - as in most cases it should skip the property that contains circular reference what would break the loop.

scyzoryck avatar Nov 11 '22 19:11 scyzoryck