[wp-trac] [WordPress Trac] #57271: Cron unschedule / reschedule event errors

WordPress Trac noreply at wordpress.org
Mon Dec 5 02:40:29 UTC 2022


#57271: Cron unschedule / reschedule event errors
---------------------------+------------------------------
 Reporter:  domainsupport  |       Owner:  audrasjb
     Type:  defect (bug)   |      Status:  assigned
 Priority:  normal         |   Milestone:  Awaiting Review
Component:  Cron API       |     Version:  6.0
 Severity:  normal         |  Resolution:
 Keywords:                 |     Focuses:
---------------------------+------------------------------

Comment (by peterwilsoncc):

 I can see that `wp_unschedule_event()` may throw an error if the event
 being unscheduled is not set. Similarly `wp_schedule_event()` may throw
 the error if the event been scheduled is already set.

 {{{
 wp> wp_unschedule_event( time() - MONTH_IN_SECONDS, '57271cc', [], true );
 => class WP_Error#2637 (3) {
   public $errors =>
   array(1) {
     'could_not_set' =>
     array(1) {
       [0] =>
       string(39) "The cron event list could not be saved."
     }
   }
   public $error_data =>
   array(0) {
   }
   protected $additional_data =>
   array(0) {
   }
 }

 wp> $event_time = time() + MONTH_IN_SECONDS;
 => int(1672799267)
 wp> wp_schedule_event( $event_time, 'weekly', '57271bcc', [], true );
 => bool(true)
 wp> wp_schedule_event( $event_time, 'weekly', '57271bcc', [], true );
 => class WP_Error#2636 (3) {
   public $errors =>
   array(1) {
     'could_not_set' =>
     array(1) {
       [0] =>
       string(39) "The cron event list could not be saved."
     }
   }
   public $error_data =>
   array(0) {
   }
   protected $additional_data =>
   array(0) {
   }
 }
 }}}

 I don't think these functions should return `could_not_set` in either of
 these circumstances. Whether the functions should return an error if
 called in this fashion is a discussion for elsewhere.

 In both of these circumstances, the scenario being hit is number two in
 the original description: the options value already matches.

 @domainsupport I noticed you mentioned in the support ticket you linked to
 that these events are not in your cron array, the leads me to suspect you
 are hitting these false error reports with `wp_unschedule_event()`.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/57271#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list