WC_Post_Data::invalidate_products_last_modified
Invalidate the cached products last modified timestamp when a product post cache is cleaned.
This does not use wp_cache_set_last_changed() because the cached value is exposed to clients via the Last-Modified HTTP header for collection cache invalidation. WordPress core's last_changed pattern auto-seeds with the current time on cache miss, which is acceptable for opaque cache-key salts but would force all clients to unnecessarily invalidate their local caches. Instead, invalidating the cache here allows the read side in ProductQuery::get_last_modified() to fall back to the DB and re-seed with the real last modification time.
Метод класса: WC_Post_Data{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
$result = WC_Post_Data::invalidate_products_last_modified( $post_id, $post ): void;
- $post_id(int) (обязательный)
- Post ID.
- $post(WP_Post) (обязательный)
- Post object.
Список изменений
| С версии 10.6.0 | Введена. |
Код WC_Post_Data::invalidate_products_last_modified() WC Post Data::invalidate products last modified WC 11.2.2
public static function invalidate_products_last_modified( $post_id, $post ): void {
if ( $post instanceof WP_Post && in_array( $post->post_type, array( 'product', 'product_variation' ), true ) ) {
wp_cache_delete( 'last_modified', 'wc_products' );
}
}