Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Run Now" doesn't work with Cavalcade #56

Open
maciejmackowiak opened this issue Mar 17, 2021 · 3 comments
Open

"Run Now" doesn't work with Cavalcade #56

maciejmackowiak opened this issue Mar 17, 2021 · 3 comments
Labels

Comments

@maciejmackowiak
Copy link

Hi,
We have run into an issue with Cavalcade and wp-crontrol,
when we use the "Run Now" button it adds the event to the database but because of this function in Cavalcade:
https://github.com/humanmade/Cavalcade/blob/771b2e114aaa5684fb2f9322a6af5a89e9ff90d0/inc/connector/namespace.php#L449
This check returns false:
https://github.com/johnbillion/wp-crontrol/blob/develop/src/event.php#L104

And it results in Failed to schedule the cron event message but the event is created.

The solution could be to replace this part:

$scheduled = force_schedule_single_event( $hookname, $event->args ); // UTC

With using the schedule_event hook like this:

add_filter('schedule_event', function($event){
	if ($event->hook == 'wp-crontrol-fake-event') {
		$event->hook = $event->args['hook'];
		$event->args = $event->args['args'];
	}
	return $event;
});
$scheduled = wp_schedule_single_event(1, 'wp-crontrol-fake-event', $event);
@archon810
Copy link

As a Cavalcade user, I'd love to see this implemented.

@archon810
Copy link

When you click Run Now, a duplicate event with 50+year (no date set or 1969 epoch time 0 I guess?) next run date is created and really scares you at first.

image

@johnbillion
Copy link
Owner

johnbillion commented Mar 17, 2021

Thanks for the report. Forcing an event to be added when WordPress core treats it as a duplicate is a complete pain, hence this function for forcibly inserting it into the cron array.

I'll take a look at your proposed solution. Won't have time soon though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants