diff --git a/includes/class-wc-cache-helper.php b/includes/class-wc-cache-helper.php index a57b85066ef..5873e0e952b 100644 --- a/includes/class-wc-cache-helper.php +++ b/includes/class-wc-cache-helper.php @@ -134,33 +134,16 @@ class WC_Cache_Helper { public static function get_transient_version( $group, $refresh = false ) { $transient_name = $group . '-transient-version'; $transient_value = get_transient( $transient_name ); - $transient_value = strval( $transient_value ? $transient_value : '' ); - if ( '' === $transient_value || true === $refresh ) { - $old_transient_value = $transient_value; - $transient_value = (string) time(); + if ( false === $transient_value || true === $refresh ) { + self::delete_version_transients( $transient_value ); - if ( $old_transient_value === $transient_value ) { - // Time did not change but transient needs flushing now. - self::delete_version_transients( $transient_value ); - } else { - self::queue_delete_version_transients( $transient_value ); - } + $transient_value = (string) time(); set_transient( $transient_name, $transient_value ); } - return $transient_value; - } - /** - * Queues a cleanup event for version transients. - * - * @param string $version Version of the transient to remove. - */ - protected static function queue_delete_version_transients( $version = '' ) { - if ( ! wp_using_ext_object_cache() && ! empty( $version ) ) { - wp_schedule_single_event( time() + 30, 'delete_version_transients', array( $version ) ); - } + return $transient_value; } /** @@ -185,7 +168,7 @@ class WC_Cache_Helper { // If affected rows is equal to limit, there are more rows to delete. Delete in 30 secs. if ( $affected === $limit ) { - self::queue_delete_version_transients( $version ); + wp_schedule_single_event( time() + 30, 'delete_version_transients', array( $version ) ); } } }