prefix . ':' . ( function_exists( 'get_current_blog_id' ) ? (int) \get_current_blog_id() : 0 ) . ':' . $product_id ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Advisory locks must not be cached. $result = $wpdb->get_var( $wpdb->prepare( 'SELECT GET_LOCK(%s, %d)', $name, 2 ) ); if ( null === $result ) { return null; } if ( '1' !== (string) $result ) { return false; } return static function () use ( $wpdb, $name ): void { // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Advisory locks must not be cached. $wpdb->get_var( $wpdb->prepare( 'SELECT RELEASE_LOCK(%s)', $name ) ); }; } }