Bug Report #2285
Many ORM method calls fail when used in overriding magic set method
|Assignee:||John Heathco||% Done:|
When calling ORM methods from within the magic set method, many ORM methods will fail (such as the 'loaded' method). This is because the magic set method is called when a Database result is cast into an ORM object. The casting is done before the object itself has been initialized, so many methods and operations will fail.
To prevent this as of now, you must run
if ( ! isset($this->_object_name)) to verify that the model is currently undergoing the Database cast. This check should be placed into the 'loaded' method (the method should return FALSE if the object is not yet initialized).
#1 Updated by John Heathco over 4 years ago
- Status changed from New to Closed
- Resolution set to fixed
The 'loaded' method of ORM will now return FALSE if the object has not been initialized by doing a check on the _object_name property.