Live Blog

Over 500,000 Transients from transient_wc_product_loop and transient_timeout_wc_product_loop in wp_options table

Issue

It was pretty wild to see 500,000 rows in the wp_options table, so I had to take a moment to take it all in.

Then I decided to dig a bit further, and that’s when I found the following transients were taking up much of the rows in the wp_options table.

transient_timeout_wc_product_loop
transient_wc_product_loop 

Resolution

After a little bit of googling, I found this issue on the WooCommerce Github project.

Transient Recreating [wc_product_loop] forces crashing WC · Issue #26678 · woocommerce/woocommerce · GitHub
Description of the Bug Two transients are produced everytime a filter is clicked on the product page. I am talking about transient_wc_product_loop% _transient_timeout_wc_product_loop%_. This happends in the database table wp_options. In …
github.com

It’s closed, but not addressed. If you read the entire issue you can see it’s still occurring, I did comment on it too.

There is also a mention from MainWP in a commit of a code snippet that hooks into the function creating these transients. Here’s the code snippet.

Code-Snippets-Functions/Execute a function on a child site/WooCommerce/change-wc_product_loop_transient-expiration-to-1-day.txt at master · mainwp/Code-Snippets-Functions · GitHub
Repository for the MainWP Code Snippets Extension functions. – Code-Snippets-Functions/Execute a function on a child site/WooCommerce/change-wc_product_loop_transient-expiration-to-1-day.txt at master · mainwp/Code-Snippets-Functions
github.com
add_action( 'setted_transient', 'mmx_wc_product_loop_transient', 50, 3 );
function mmx_wc_product_loop_transient( $transient, $value, $expiration ){
	$pos = strpos( $transient, 'wc_product_loop_' );
	if ( $pos !== false && $expiration == 2592000 ) {
		set_transient( $transient, $value, DAY_IN_SECONDS );
	}
}

I’ve also add the code to the Managing WP WordPress Code Snippets github repository.

GitHub – managingwp/wordpress-code-snippets: Code snippets for WordPress
Code snippets for WordPress. Contribute to managingwp/wordpress-code-snippets development by creating an account on GitHub.
github.com
0 Shares: