I have a plugin that retrieves a bool from a mySQL server when a hook is called.
My issue is that the SQL query seems to run in parallel with the code after it.
The way it is set up and intended to work:
1. Hook triggered
2. bool = SQLGetBoolFromDBFunction
3. if statement returns null/true based on bool from db
The issue is that the execution seems to happening like this (based on debug inserts):
1. Hook triggered
2. bool = SQLGetBoolFromDBFunction gets started
3. if statment uses default value for bool
4. bool = SQLGetBoolFromDBFunction finishes
Is there a way to force the SQL query to finish before moving on?
Plugin code not running in correct orderNot An Issue
No, as it runs the background to prevent locking up the server. You may be able to do a callback, but unsure.
One option that i ended up using in testing is just having the user trigger the hook twice, getting the bool from the db the first time and triggering the action the second. Doing two actions is annoying but gets the job done.
I will try using a callback.
I will try using a callback.
Triggering the method again right away would not be reliable, as you don't know how long the query would take.
Locked automatically