Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

sajtdavid on "Cron problem"

$
0
0

Hi!

I'm trying to schedule events but it acts very weird.

Schedule command:
wp_schedule_single_event( strtotime($_REQUEST['newtime']) - 3600 + 10, 'event_for_new_home_post_trigger' );

I ran it multiple times, and sometimes it worked sometimes it is not.
Downloaded this plugin:
https://wordpress.org/plugins/cron-view/

and saw only 2 entries, while there should be more than 5.

dumped the output of the function and I got false, however there was no new entry at the cron view plugin. Checked the core cron.php, and found this line:

$next = wp_next_scheduled($hook, $args);
	if ( $next && $next <= $timestamp + 10 * MINUTE_IN_SECONDS ) {return}

So if there is a same event close to the new, it returns null.
The docs can be confusing here, since it says:

(boolean|null)
False if the event was cancelled by a plugin, null otherwise.

I wanted to find out which event is next to my event, so I ran wp_get_schedule, and it returned nothing.
I used the wp_next_scheduled command too, and it returned the next event:

var_dump(wp_next_scheduled('event_for_new_home_post_trigger'));
	var_dump(wp_get_schedule( 'event_for_new_home_post_trigger' ));

=>

int(1415340010) bool(false)

So I got no schedule, but I got the next schedule.. how is this possible?

Thanks for any kind of help.


Viewing all articles
Browse latest Browse all 8245

Trending Articles