returnnew\WP_Error('missing-data',__('Invalid or incomplete request data.','automattic-cron-control'),array('status'=>400,));
returnnew\WP_Error('missing-data',__('Invalid or incomplete request data.','automattic-cron-control'),array(
'status'=>400,
));
}
// Ensure we don't run jobs ahead of time
// Ensure we don't run jobs ahead of time.
if(!$force&&$timestamp>time()){
returnnew\WP_Error('premature',sprintf(__('Job with identifier `%1$s` is not scheduled to run yet.','automattic-cron-control'),"$timestamp-$action-$instance"),array('status'=>403,));
/* translators: 1: Job identifier */
returnnew\WP_Error('premature',sprintf(__('Job with identifier `%1$s` is not scheduled to run yet.','automattic-cron-control'),"$timestamp-$action-$instance"),array(
'status'=>403,
));
}
// Find the event to retrieve the full arguments
// Find the event to retrieve the full arguments.
$event=get_event_by_attributes(array(
'timestamp'=>$timestamp,
'action_hashed'=>$action,
...
...
@@ -252,57 +276,67 @@ class Events extends Singleton {
// Nothing to do...
if(!is_object($event)){
returnnew\WP_Error('no-event',sprintf(__('Job with identifier `%1$s` could not be found.','automattic-cron-control'),"$timestamp-$action-$instance"),array('status'=>404,));
/* translators: 1: Job identifier */
returnnew\WP_Error('no-event',sprintf(__('Job with identifier `%1$s` could not be found.','automattic-cron-control'),"$timestamp-$action-$instance"),array(
'status'=>404,
));
}
unset($timestamp,$action,$instance);
// Limit how many events are processed concurrently, unless explicitly bypassed
// Limit how many events are processed concurrently, unless explicitly bypassed.
if(!$force){
// Prepare event-level lock
// Prepare event-level lock.
$this->prime_event_action_lock($event);
if(!$this->can_run_event($event)){
returnnew\WP_Error('no-free-threads',sprintf(__('No resources available to run the job with action action `%1$s` and arguments `%2$s`.','automattic-cron-control'),$event->action,maybe_serialize($event->args)),array('status'=>429,));
returnnew\WP_Error('no-free-threads',sprintf(__('No resources available to run the job with action `%1$s` and arguments `%2$s`.','automattic-cron-control'),$event->action,maybe_serialize($event->args)),array(
'status'=>429,
));
}
// Free locks should event throw uncatchable error
// Free locks should event throw uncatchable error.
/* translators: 1: Event action, 2: Event arguments, 3: Throwable error, 4: Line number that raised Throwable error */
'message'=>sprintf(__('Callback for job with action `%1$s` and arguments `%2$s` raised a Throwable - %3$s in %4$s on line %5$d.','automattic-cron-control'),$event->action,maybe_serialize($event->args),$t->getMessage(),$t->getFile(),$t->getLine()),
);
}
// Free locks for the next event, unless they weren't set to begin with
// Free locks for the next event, unless they weren't set to begin with.
if(!$force){
// If we got this far, there's no uncaught error to handle
// If we got this far, there's no uncaught error to handle.
'message'=>sprintf(__('Job with action `%1$s` and arguments `%2$s` executed.','automattic-cron-control'),$event->action,maybe_serialize($event->args)),
);
}
...
...
@@ -315,7 +349,7 @@ class Events extends Singleton {
*
* Used to ensure only one instance of a particular event, such as `wp_version_check` runs at one time