Infinite loop toArray()
DylandeWit opened this issue · comments
Dylan de Wit commented
Context:
Monkey has a Banana. Banana has a Monkey.
Get request on Monkey with Banana included.
Monkey also gets loaded in Banana because of relationships but Monkey is not included with Banana.
Problem:
When you call toArray on Monkey's Banana and Banana calls toArray on Monkey, you end up with an unintended infinite loop.
Dirty fix:
$this->banana->setRelation('monkey', new JenssegersItem());
Recommended fix:
$this->banana->excludeRelation('monkey');
Björn Brala commented
Have not heard of people having this issue anymore. Should you still see this issue happening, please reopen this issue.