wordpress - wp_cron scheduled but not firing -
i trying run background script fired on user action using wp_schedule_single_event, , although have confirmed event being scheduled , wp_cron recognizes scheduled time has passed, not fire event handler. further complicate things, code runs fine on local wp install, nothing on server.
to schedule event, using:
if ( ! wp_next_scheduled( 'my_action_name' ) ) { wp_schedule_single_event( time(), 'my_action_name' ); }
my handler action defined as:
add_action('my_action_name', 'my_action_handler'); function my_action_handler () { // stuff }
i have testing wp core files , found following block (from wp-includes/cron.php:322) script terminates:
var_dump('test1'); $cron_request = apply_filters( 'cron_request', array( 'url' => add_query_arg( 'doing_wp_cron', $doing_wp_cron, site_url( 'wp-cron.php' ) ), 'key' => $doing_wp_cron, 'args' => array( 'timeout' => 0.01, 'blocking' => false, /** filter documented in wp-includes/class-wp-http-streams.php */ 'sslverify' => apply_filters( 'https_local_ssl_verify', false ) ) ), $doing_wp_cron ); var_dump('test2'); //exit here test wp_remote_post( $cron_request['url'], $cron_request['args'] );
on local machine, filter applied, 'test2' printed, , script can continue call wp_remote_post. on server, however, script terminates during execution of apply_filter('cron_request'), printing 'test1' not 'test2' , failing reach wp_remost_post.
i have been unable find source filter further debug. wordpress.org says filter defined within wp-includes/cron.php , 1 instance have cited place ever applied, however, using sublime multi-file search reveals string 'cron_request' appears in filter application have cited.
i have read many post on wp_cron failing , have found no other non-descript 'server configuration blocking wp_cron' answers. additional information on type of server config or else occuring here?
this action trigger when visits wordpress site, if scheduled time has passed.
maybe can use
wp_schedule_event()
instead of
wp_schedule_single_event()
Comments
Post a Comment