[wp-trac] [WordPress Trac] #52448: wp_scheduled_delete WP-Cron Job Cannot Be Unscheduled

WordPress Trac noreply at wordpress.org
Thu Feb 4 16:06:36 UTC 2021


#52448: wp_scheduled_delete WP-Cron Job Cannot Be Unscheduled
----------------------------+-----------------------------
 Reporter:  daleharrison    |      Owner:  (none)
     Type:  defect (bug)    |     Status:  new
 Priority:  normal          |  Milestone:  Awaiting Review
Component:  Administration  |    Version:  4.9
 Severity:  normal          |   Keywords:
  Focuses:                  |
----------------------------+-----------------------------
 My organization has disabled automatic trash deletion to preserve history
 on a large multisite network we host. We have done this via the following
 method:

 {{{#!php
 <?php
 remove_action( 'wp_scheduled_delete', 'wp_scheduled_delete' );
 }}}

 What we've noticed, however, is that WordPress still schedules the WP-Cron
 job of the same name (`wp_scheduled_delete`), and there does not appear to
 be a mechanism for disabling it.

 `wp_unschedule_event()` is not capable of unscheduling the event because
 WordPress core always tries to schedule it if it's not already scheduled
 in `wp-admin/admin.php`:

 {{{#!php
 <?php
 // Schedule Trash collection.
 if ( ! wp_next_scheduled( 'wp_scheduled_delete' ) && ! wp_installing() ) {
         wp_schedule_event( time(), 'daily', 'wp_scheduled_delete' );
 }
 }}}

 The WP-Crontrol plugin shows a persistent warning about this, which is how
 we discovered it. See attached screenshot.

 We are currently using WordPress 4.9.16, but it appears that the code
 noted above is the same in version 5.6.

 What I would like to see is a better filter for this purpose that both
 removes the action and prevents the WP-Cron job from being (re)scheduled.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/52448>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list