propelorm / Propel

Current stable (and outdated and unmaintained) version of Propel - Please use v2 https://github.com/propelorm/Propel2 --
http://www.propelorm.org
MIT License
841 stars 417 forks source link

Infinite Loop In Reverse #736

Open danomatic opened 11 years ago

danomatic commented 11 years ago

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 11 years ago

May you provide a simplified schema which shows the problem?

danomatic commented 11 years ago

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.

danomatic commented 11 years ago

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