plugin updates

This commit is contained in:
Tony Volpe
2024-11-15 13:53:04 -05:00
parent 1293d604ca
commit 0238f0c4ca
2009 changed files with 163492 additions and 89543 deletions

View File

@@ -145,8 +145,35 @@ class WC_Product_Data_Store_CPT extends WC_Data_Store_WP implements WC_Object_Da
return boolval( $locked );
}
// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
$result = $wpdb->query( $query );
// The insert query can potentially result in a deadlock if there is high concurrency
// when trying to insert products, which will result in a false negative for SKU lock
// and incorrectly products not being created.
// To mitigate this, we will retry the query 3 times before giving up.
for ( $attempts = 0; $attempts < 3; $attempts++ ) {
if ( $attempts > 1 ) {
usleep( 10000 );
}
// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
$result = $wpdb->query( $query );
if ( false !== $result ) {
break;
}
}
if ( false === $result ) {
wc_get_logger()->warning(
sprintf(
'Failed to obtain SKU lock for product: ID "%d" with SKU "%s" after %d attempts.',
$product_id,
$sku,
$attempts,
),
array(
'error' => $wpdb->last_error,
)
);
}
return (bool) $result;
}