Don't schedule event to delete transients if limit set to 0
Third-party code can set the limit of transients to be deleted to 0 using the filter `woocommerce_delete_version_transients_limit`. If this happens, the code shouldn't schedule a cron event to delete more transients to avoid flooding the list of cron jobs. Fixes #19890
This commit is contained in:
parent
9e3d373cd6
commit
18a8a6b752
|
@ -161,7 +161,7 @@ class WC_Cache_Helper {
|
|||
$affected = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->options} WHERE option_name LIKE %s ORDER BY option_id LIMIT %d;", '\_transient\_%' . $version, $limit ) ); // WPCS: cache ok, db call ok.
|
||||
|
||||
// If affected rows is equal to limit, there are more rows to delete. Delete in 10 secs.
|
||||
if ( $affected === $limit ) {
|
||||
if ( $affected === $limit && 0 !== $limit ) {
|
||||
wp_schedule_single_event( time() + 10, 'delete_version_transients', array( $version ) );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue