Commit ac8b28d2ac6 for woocommerce

commit ac8b28d2ac62d026ccf21e57037cb4afef73d13b
Author: Brandon Kraft <public@brandonkraft.com>
Date:   Mon Aug 24 05:45:29 2026 -0500

    Fix transient version same-second invalidation (#64604)

    * Fix transient version same-second invalidation

diff --git a/plugins/woocommerce/changelog/fix-64557-transient-version-precision b/plugins/woocommerce/changelog/fix-64557-transient-version-precision
new file mode 100644
index 00000000000..862d857c67c
--- /dev/null
+++ b/plugins/woocommerce/changelog/fix-64557-transient-version-precision
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Fix cache invalidation no-ops when transient versions refresh within the same second.
diff --git a/plugins/woocommerce/includes/class-wc-cache-helper.php b/plugins/woocommerce/includes/class-wc-cache-helper.php
index 51bff4db3e3..6e7b84c307b 100644
--- a/plugins/woocommerce/includes/class-wc-cache-helper.php
+++ b/plugins/woocommerce/includes/class-wc-cache-helper.php
@@ -243,7 +243,7 @@ class WC_Cache_Helper {
 	 * delete transients manually.
 	 *
 	 * With external cache however, this isn't possible. Instead, this function is used
-	 * to append a unique string (based on time()) to each transient. When transients
+	 * to append a unique string (based on microtime()) to each transient. When transients
 	 * are invalidated, the transient version will increment and data will be regenerated.
 	 *
 	 * Raised in issue https://github.com/woocommerce/woocommerce/issues/5777.
@@ -251,14 +251,14 @@ class WC_Cache_Helper {
 	 *
 	 * @param  string  $group   Name for the group of transients we need to invalidate.
 	 * @param  boolean $refresh true to force a new version.
-	 * @return string transient version based on time(), 10 digits.
+	 * @return string transient version.
 	 */
 	public static function get_transient_version( $group, $refresh = false ) {
 		$transient_name  = $group . '-transient-version';
 		$transient_value = get_transient( $transient_name );

 		if ( false === $transient_value || true === $refresh ) {
-			$transient_value = (string) time();
+			$transient_value = sprintf( '%.6F', microtime( true ) );

 			set_transient( $transient_name, $transient_value );
 		}
diff --git a/plugins/woocommerce/tests/php/includes/class-wc-cache-helper-test.php b/plugins/woocommerce/tests/php/includes/class-wc-cache-helper-test.php
index 80dcbc90f50..a0770fb7d8a 100644
--- a/plugins/woocommerce/tests/php/includes/class-wc-cache-helper-test.php
+++ b/plugins/woocommerce/tests/php/includes/class-wc-cache-helper-test.php
@@ -25,6 +25,34 @@ class WC_Cache_Helper_Tests extends WC_Unit_Test_Case {
 		parent::tearDown();
 	}

+	/**
+	 * @testdox Should refresh transient versions within the same second.
+	 */
+	public function test_get_transient_version_refreshes_within_same_second(): void {
+		$group          = 'test-cache-helper-version';
+		$transient_name = $group . '-transient-version';
+
+		delete_transient( $transient_name );
+
+		$current_time = microtime( true );
+		while ( 0.1 < $current_time - floor( $current_time ) ) {
+			usleep( 1000 );
+			$current_time = microtime( true );
+		}
+
+		$first_version = WC_Cache_Helper::get_transient_version( $group, true );
+		usleep( 1000 );
+		$second_version = WC_Cache_Helper::get_transient_version( $group, true );
+
+		delete_transient( $transient_name );
+
+		$this->assertNotSame(
+			$first_version,
+			$second_version,
+			'Refreshing a transient version should always create a new cache version.'
+		);
+	}
+
 	/**
 	 * Data provider for test_geolocation_ajax_get_location_hash.
 	 *