Infinite Loop In Reverse #736

danomatic opened this Issue Aug 9, 2013 · 3 comments


None yet

2 participants


Our team sometimes experiences a crash when doing a reverse engineer of a schema. We've traced it to the model/Column.php class:

public function hasReferrer(ForeignKey $fk)
    return $this->hasReferrers() && in_array($fk, $this->referrers);

Adding a "true" as the third argument for strict checking fixes the issue.

staabm commented Aug 9, 2013

May you provide a simplified schema which shows the problem?

@staabm staabm closed this Aug 9, 2013
@staabm staabm reopened this Aug 9, 2013

I haven't been able to figure out the exact cause yet, because the recursion occurs in in_array. We may have some sort of circular foreign key which is brining out the issue, but we haven't found it yet. All I know so far is that for this method, using in_array without the true sometimes leads to a crash due to recursion. I think PHP treats the objects like arrays and traverses them unless strict is true. If the objects have circular references, the traversal would become infinite and cause this error. If that is true, adding the true is likely a performance benefit.


This would probably be a good idea anywhere in_array is being used with arrays of objects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment