Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Issue with Observer Self
  • Hi, 

    Just wanna make sure that it's a bug, and not intended as it before I send a PR.

    1. Create two models, (let's say, director and movie) with director having a has_many relationship defined to the movie one.
    2. Get the director model with the movie relation. At this point, if you check the profiler, you have one request with a join for the relation.
    3. Add an Observer_Self to the director model with the event after_load. In the _event_after_load method, simply access the movie relation.
    4. Check the profiler and note that there are now 2 requests. The first one same as before, and another one which would be the lazy loaded relation in a normal case.

    Do you confirm that it's not intended this way ? (Which wouldn't make sense).

    Solution : (Didn't dig in the code yet, it's only a theorical guess) Move the after_load call after the model loaded the relations in the package/orm/classes/model.php

    Have a nice day 
  • HarroHarro
    Accepted Answer
    My gut feeling is, this is not ok.

    The ORM should run the query and process it's result before running observers.
  • OK then, I will PR a fix.
  • Thanks !

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion