-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #84 from swagindustries/doc-circular-reference
📝 Add troubleshooting section
- Loading branch information
Showing
3 changed files
with
39 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Troubleshooting | ||
|
||
_Here is a list of classic error you may experiment with Melodiia and how to fix it_ | ||
|
||
|
||
### Blank page on documentation | ||
|
||
You probably forget to install assets. `bin/console assets:install`. | ||
|
||
## Uncaught PHP Exception Symfony\Component\Serializer\Exception\CircularReferenceException | ||
|
||
This error is disturbing but not related to Melodiia. It happens because you return an object that have a reference to | ||
itself in one of its children (or sub-children). | ||
|
||
Let's consider the following couple of entities: | ||
|
||
```php | ||
class Product | ||
{ | ||
public ArrayCollection $variants; | ||
} | ||
|
||
class Variant | ||
{ | ||
public Product $product; | ||
} | ||
``` | ||
|
||
When Melodiia tries to serialize your product, it will also serialize the variants associated to the product, then the product itself. | ||
|
||
The serializer is well-designed and detect this issue, this is why you're getting this exception instead of an infinite loop! | ||
|
||
To fix it, you need to use serialization groups, it's | ||
[documented on Symfony documentation](https://symfony.com/doc/current/serializer.html#using-serialization-groups-attributes). |