fuel / orm

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

Problem with order of executing query in observer #411

Closed huuphuc2401 closed 7 years ago

huuphuc2401 commented 7 years ago

I have an Model_M with 2 observers:

I add Observer A and B to Model_M with order: A first and B later.

I debug in php and see that the process write log is run first and calculating is run later

Expected result

calculating process can find the log

Result

calculate process can not find the log (I checked in Profiling, the sql query of calculating is executed before the sql query of write log)

WanWizard commented 7 years ago

The query is executed when you say it has to be executed, so when you call save() on the object.

You'll have to debug further, perhaps observers on related models that interfere? You can use Debug::backtrace() to output the call path if you want to see how you got to a certain place in the code.

huuphuc2401 commented 7 years ago

@WanWizard I used Debug::backtrace() and found problem (observers on related models as you said). Thank you so much.

WanWizard commented 7 years ago

You're welcome.