I am running background job by using add_action hook, hook starts on REST API CALL:
if ( ! wp_next_scheduled( 'bg_job_hook' ) ) {
wp_schedule_single_event( time(), 'bg_job_hook');
get_headers(get_site_url());
}
add_action( 'bg_job_hook', array( $this->$bg, 'do_background' ) );
it works fine, but I would to quit this job, so on another api call I add an option, and inside background job I get this option on every loop. I see that this quit option is updated in DB, but logs from loop shows me that not. If iteration quits, and I will background job again, it will after first loop because get_option shows true..
Why during loop it is not working ?
I am running background job by using add_action hook, hook starts on REST API CALL:
if ( ! wp_next_scheduled( 'bg_job_hook' ) ) {
wp_schedule_single_event( time(), 'bg_job_hook');
get_headers(get_site_url());
}
add_action( 'bg_job_hook', array( $this->$bg, 'do_background' ) );
it works fine, but I would to quit this job, so on another api call I add an option, and inside background job I get this option on every loop. I see that this quit option is updated in DB, but logs from loop shows me that not. If iteration quits, and I will background job again, it will after first loop because get_option shows true..
Why during loop it is not working ?
Share Improve this question asked May 18, 2019 at 18:40 FrancMoFrancMo 1537 bronze badges1 Answer
Reset to default 0Ok for some reason caching works strange in WP :) So I resigned from using get_option, and I am doing pure SQL query to DB, and everything works fine.