Skip to content

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

@maciejmackowiak

Description

@maciejmackowiak

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);

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions