Bug Report #2285

Many ORM method calls fail when used in overriding magic set method

Added by John Heathco almost 5 years ago. Updated over 4 years ago.

Status:ClosedStart date:10/28/2009
Priority:LowDue date:
Assignee:John Heathco% Done:

0%

Category:Modules:ORM
Target version:v3.0.2
Resolution:fixed Points:

Description

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).

Associated revisions

History

#1 Updated by John Heathco almost 5 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.

Fixed in http://github.com/kohana/orm/commit/2a6b9e977e3389d5ac4817ce127e212ce83f5d0c

#2 Updated by Woody Gilk over 4 years ago

  • Project changed from Kohana v3.x to 78
  • Category deleted (Modules:ORM)
  • Target version deleted (v3.0.2)

#3 Updated by Woody Gilk over 4 years ago

  • Project changed from 78 to Kohana v3.x

#4 Updated by Woody Gilk over 4 years ago

  • Category set to Modules:ORM

#5 Updated by Woody Gilk over 4 years ago

  • Assignee set to John Heathco
  • Target version set to v3.0.2

Also available in: Atom PDF