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:
Rodrigo Primo 2018-04-27 10:31:45 -03:00
parent 9e3d373cd6
commit 18a8a6b752
1 changed files with 1 additions and 1 deletions

View File

@ -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 ) );
}
}