Skip to content Skip to sidebar

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 2 replies, has 1 voice.

Last updated by tadsikanS 2 weeks ago.

Author Posts
March 27, 2026 at 1:42 pm #17932468

tadsikanS

We noticed that in woocommerce-multilingual/inc/class-wcml-comments.php, the maybe_invalidate_comment_cache method is hooked to pre_get_comments and calls wp_cache_flush_group('comment-queries') on every product page load:

phppublic function maybe_invalidate_comment_cache( $query ) {
if ( isset( $query->query_vars['post_id'] ) && $query->query_vars['post_id'] ) {
$product_id = $query->query_vars['post_id'];

if ( 'product' === get_post_type( $product_id ) ) {
wp_cache_flush_group( 'comment-queries' );
}
}
}
On our store this is causing significant Redis slowdowns because the flush operation has to scan millions of keys each time a product page is visited. We can see this clearly in our Redis slow log where the same EVAL command scanning comment-queries:* takes 1.5-1.7 seconds and repeats every few seconds continuously.

Is this behavior intentional? Is there a reason the cache needs to be flushed on every product page load rather than only when a review is actually added or changed?

March 27, 2026 at 5:30 pm #17933068

Juan de Paco
Supporter

Hello.

Thanks for reaching out and for the detailed report.

I am raising this directly to our development team to review. We recently conducted an analysis against our WCML plugin and object cache, and this logic was introduced as a result - I am getting our development team involved and we will check it as soon as possible.

Until I get a response, you may want to disable the whole logic by commenting out the line 80 of the file that you referenced:

//add_action( 'pre_get_comments', [ $this, 'maybe_invalidate_comment_cache' ] );

I can not state if there can be some side effect of this workaround, to be honest, until I get some feedback from our development team. You might experience some comments not appearing right after they are created, or even some mismatch between the language of the content being visited and the comments being displayed.

I will update here once I know more.

Thanks.

March 30, 2026 at 3:59 am #17935042

tadsikanS

Thank you Juan. I can confirm that your hotfix worked and the situation stabilized. Please kindly keep us posted on a long-term solution so we don't have to rely on commenting out that specific line.

I think the issue might unknowingly slow down a lot of websites from many of your customers, and it is quite hard to identify this problem, so your help in escalating this to the devs is much appreciated.