[wp-trac] [WordPress Trac] #58470: Add configurable batching to `wp_scheduled_delete` for controlling cleanup operations

WordPress Trac noreply at wordpress.org
Wed Jun 7 00:14:03 UTC 2023


#58470: Add configurable batching to `wp_scheduled_delete` for controlling cleanup
operations
-------------------------+------------------------------
 Reporter:  johnrom      |       Owner:  (none)
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  Cron API     |     Version:  trunk
 Severity:  normal       |  Resolution:
 Keywords:               |     Focuses:  performance
-------------------------+------------------------------

Comment (by peterwilsoncc):

 The frequency of the task can be modified via the `schedule_event` filter
 using code similar to that below (untested but you'll get the idea if it
 needs fixing).

 {{{#!php
 <?php
 add_filter( 'schedule_event', function( $event ) {
         if ( 'wp_scheduled_delete' !== $event->hook ) {
                 return $event;
         }

         $event->schedule = 'twicedaily'; /* or hourly/custom schedule name
 */


         return $event;
 } );
 }}}

 Allowing plugin authors to modify the batch size seems like it could be
 helpful but rather than using a constant (WordPress aims to avoid them
 when possible) I think a filter in `wp_scheduled_delete` would be a better
 approach.

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


More information about the wp-trac mailing list