fuel/orm — Issue #117: Saving a Model with (non-populated) Relations throws an Orm\FrozenObject Exception
Author: SicoAnimal
Created: 2011-11-04 09:40:43+00:00
State: open

Changes have been made to `Orm\Model::is_changed()` whereby it tries to populate a models relations when that model is saved (this seems to be triggered when `Orm\Model::$_original_relations` is accessed).

As it is a save the `Orm\Model` object is frozen, meaning that when `Orm\Query::hydrate()` calls `Orm\Model::_relate()` the latter's `if ($this->_frozen)` check throws an `Orm\FrozenObject` exception.

If the elseif and else here - https://github.com/fuel/orm/blob/1.1/develop/classes/model.php#L1248 - are commented out then everything seems to work fine.

IMO, loading all of the relations on a model when it is saved is a bad idea, as the model being saved could have several has_many or many_many relations which have not been populated for the reason that they could be huge and use a lot of memory when loaded.