最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

plugins - Force quit running background job

programmeradmin0浏览0评论

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 badges
Add a comment  | 

1 Answer 1

Reset to default 0

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

发布评论

评论列表(0)

  1. 暂无评论