Commit 69661a58 authored by Erick Hitter's avatar Erick Hitter Committed by GitHub
Browse files

Merge pull request #74 from Automattic/develop

If an event has no callbacks hooked to its action, skip it
parents 6770a263 91fd1cd8
......@@ -65,6 +65,19 @@ class Events extends Singleton {
continue;
}
// Skip events that don't have any callbacks hooked to their actions, unless their execution is requested
if ( false === has_action( $event['action'] ) && ! apply_filters( 'a8c_cron_control_run_event_with_no_callbacks', false, $event ) ) {
if ( false === $event['args']['schedule'] ) {
wp_unschedule_event( $event['timestamp'], $event['action'], $event['args']['args'] );
} else {
$timestamp = $event['timestamp'] + ( isset( $event['args']['interval'] ) ? $event['args']['interval'] : 0 );
wp_reschedule_event( $timestamp, $event['args']['schedule'], $event['action'], $event['args']['args'] );
unset( $timestamp );
}
continue;
}
// Necessary data to identify an individual event
// `$event['action']` is hashed to avoid information disclosure
// Core hashes `$event['instance']` for us
......
......@@ -13,6 +13,9 @@ class Utils {
'args' => array(),
);
// Plugin skips events with no callbacks
add_action( 'a8c_cron_control_test_event', '__return_true' );
if ( $allow_multiple ) {
$event['action'] .= '_' . rand( 10, 100 );
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment