WC_Cache_Helper::delete_version_transients
Устарела с версии 3.6.0 Adjusted transient usage to include versions within the transient values, making this cleanup obsolete.. Больше не поддерживается и может быть удалена. Рекомендуется заменить эту функцию на аналог.
When the transient version increases, this is used to remove all past transients to avoid filling the DB.
Note; this only works on transients appended with the transient version, and when object caching is not being used.
Метод класса: WC_Cache_Helper{}
Хуки из метода
Возвращает
null. Ничего (null).
Использование
$result = WC_Cache_Helper::delete_version_transients( $version );
- $version(строка)
- Version of the transient to remove.
По умолчанию:''
Список изменений
| С версии 2.3.10 | Введена. |
| Устарела с 3.6.0 | Adjusted transient usage to include versions within the transient values, making this cleanup obsolete. |
Код WC_Cache_Helper::delete_version_transients() WC Cache Helper::delete version transients WC 11.2.2
public static function delete_version_transients( $version = '' ) {
if ( ! wp_using_ext_object_cache() && ! empty( $version ) ) {
global $wpdb;
$limit = apply_filters( 'woocommerce_delete_version_transients_limit', 1000 );
if ( ! $limit ) {
return;
}
$affected = $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->options} WHERE option_name LIKE %s LIMIT %d;", '\_transient\_%' . $version, $limit ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Direct deletion is required for bounded transient cleanup; caching a DELETE is not applicable.
// If affected rows is equal to limit, there are more rows to delete. Delete in 30 secs.
if ( $affected === $limit ) {
wp_schedule_single_event( time() + 30, 'delete_version_transients', array( $version ) );
}
}
}