fuel / orm

Fuel PHP Framework - Fuel v1.x ORM
http://fuelphp.com/docs/packages/orm/intro.html
152 stars 96 forks source link

Out of memory on to_array #295

Closed jraede closed 11 years ago

jraede commented 11 years ago

This is RE: the fix I suggested here: http://fuelphp.com/forums/discussion/12540/to_array-bug-with-nested-singular-relations

The issue now is that adding the model class to the array references should happen BEFORE running $rel->to_array(). As it is now, with a relationship model of:

STORE has many PRODUCTS PRODUCT belongs to STORE

It will loop through the store's related products, then get down to line 1916, add the product's store, then get down to line 1898, add all products again, then for each product get down to line 1916, etc. Essentially lines 1917 and 1916 should switch places so that the store model only gets added once.

WanWizard commented 11 years ago

From the looks of it, the current classname doesn't get stored at all, so it will recurse back into Store anyway. Some serious refactoring is needed here.

WanWizard commented 11 years ago

Can you check if this fixes it, and if not, re-open this issue? I'm not in a position to test much atm...

jraede commented 11 years ago

Yep, looks like that fixed it.

WanWizard commented 11 years ago

Cool, thanks for the feedback.