Skip to content

Commit 1c6cbc3

Browse files
author
Hai Zheng
committed
v7.9.2-b69: * **3rd** WooCommerce Advanced Bulk Edit now purges each edited product once per save instead of once per edited column.
1 parent 18b5043 commit 1c6cbc3

4 files changed

Lines changed: 37 additions & 15 deletions

File tree

‎litespeed-cache.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Plugin Name: LiteSpeed Cache
44
* Plugin URI: https://www.litespeedtech.com/products/cache-plugins/wordpress-acceleration
55
* Description: High-performance page caching and site optimization from LiteSpeed
6-
* Version: 7.9.2-b62
6+
* Version: 7.9.2-b69
77
* Author: LiteSpeed Technologies
88
* Author URI: https://www.litespeedtech.com
99
* License: GPLv3
@@ -35,7 +35,7 @@
3535
return;
3636
}
3737

38-
! defined( 'LSCWP_V' ) && define( 'LSCWP_V', '7.9.2-b62' );
38+
! defined( 'LSCWP_V' ) && define( 'LSCWP_V', '7.9.2-b69' );
3939

4040
! defined( 'LSCWP_CONTENT_DIR' ) && define( 'LSCWP_CONTENT_DIR', WP_CONTENT_DIR );
4141
! defined( 'LSCWP_DIR' ) && define( 'LSCWP_DIR', __DIR__ . '/' ); // Full absolute path '/var/www/html/***/wp-content/plugins/litespeed-cache/' or MU

‎src/crawler.cls.php‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,6 +1174,8 @@ private function _get_curl_options( $crawler_only = false ) {
11741174
CURLOPT_HEADER => true,
11751175
CURLOPT_CUSTOMREQUEST => 'GET',
11761176
CURLOPT_FOLLOWLOCATION => false,
1177+
CURLOPT_PROTOCOLS => CURLPROTO_HTTP | CURLPROTO_HTTPS,
1178+
CURLOPT_REDIR_PROTOCOLS => CURLPROTO_HTTP | CURLPROTO_HTTPS,
11771179
CURLOPT_ENCODING => 'gzip',
11781180
CURLOPT_CONNECTTIMEOUT => 10,
11791181
CURLOPT_TIMEOUT => $crawler_timeout, // Larger timeout to avoid incorrect blacklist addition #900171.

‎src/task.cls.php‎

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ class Task extends Root {
2222
*/
2323
const LOG_TAG = '⏰';
2424

25+
/**
26+
* Async job types accepted by async_call() and async_litespeed_handler().
27+
*
28+
* @var string[]
29+
*/
30+
const ASYNC_TYPES = [ 'crawler', 'crawler_force', 'imgoptm', 'imgoptm_force' ];
31+
2532
/**
2633
* Map of option id => cron hook registration.
2734
*
@@ -192,16 +199,20 @@ public function init() {
192199
* @return void
193200
*/
194201
public static function async_litespeed_handler() {
195-
$type = Router::verify_type();
202+
$type = Router::verify_type();
203+
if ( ! in_array( $type, self::ASYNC_TYPES, true ) ) {
204+
return;
205+
}
206+
196207
$key = 'async_call-hash.' . $type;
197208
$hash_data = self::get_option( $key, [] );
198209
if ( ! $hash_data || ! is_array( $hash_data ) || empty( $hash_data['hash'] ) || empty( $hash_data['ts'] ) ) {
199-
self::debug( 'async_litespeed_handler no hash data', $hash_data );
210+
self::debug( 'async_litespeed_handler no hash data' );
200211
return;
201212
}
202213

203214
$nonce = isset( $_GET['nonce'] ) ? sanitize_text_field( wp_unslash( $_GET['nonce'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
204-
if ( 120 < time() - (int) $hash_data['ts'] || '' === $nonce || ! hash_equals( $hash_data['hash'], $nonce ) ) {
215+
if ( 120 < time() - (int) $hash_data['ts'] || '' === $nonce || ! is_string( $hash_data['hash'] ) || ! hash_equals( $hash_data['hash'], $nonce ) ) {
205216
self::debug( 'async_litespeed_handler nonce mismatch' );
206217
return;
207218
}
@@ -239,6 +250,10 @@ public static function async_litespeed_handler() {
239250
* @return void
240251
*/
241252
public static function async_call( $type ) {
253+
if ( ! in_array( $type, self::ASYNC_TYPES, true ) ) {
254+
return;
255+
}
256+
242257
$hash = Str::rrand( 32 );
243258
self::update_option(
244259
'async_call-hash.' . $type,

‎thirdparty/woocommerce.cls.php‎

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ function ( $cookie_list ) {
146146
* @return mixed
147147
*/
148148
public function nocache_store_api( $result, $server, $request ) {
149-
$route = $request->get_route();
150-
if ( '/wc/store/' === substr( $route, 0, 10 ) || '/wc/store' === $route ) {
149+
$route = is_object( $request ) && is_callable( [ $request, 'get_route' ] ) ? $request->get_route() : '';
150+
if ( is_string( $route ) && ( '/wc/store/' === substr( $route, 0, 10 ) || '/wc/store' === $route ) ) {
151151
Control::set_nocache_hard( 'WooCommerce Store API' );
152152
}
153153
return $result;
@@ -1056,7 +1056,7 @@ public static function bulk_edit_purge() {
10561056
* )
10571057
* )
10581058
*/
1059-
$stock_string_arr = [];
1059+
$product_ids = [];
10601060

10611061
// Ensure data is unslashed before processing.
10621062
// phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Third-party plugin may not send nonce. Data format defined by third-party plugin.
@@ -1066,18 +1066,23 @@ public static function bulk_edit_purge() {
10661066
if ( ! is_string( $stock_value ) ) {
10671067
continue;
10681068
}
1069-
$stock_string_arr = array_merge( $stock_string_arr, explode( '#^#', $stock_value ) );
1069+
foreach ( explode( '#^#', $stock_value ) as $edited_stock ) {
1070+
$product_id = (int) strtok( $edited_stock, '$' );
1071+
if ( $product_id > 0 ) {
1072+
$product_ids[ $product_id ] = true;
1073+
}
1074+
}
10701075
}
10711076

1072-
$lscwp_3rd_woocommerce = new self();
1073-
1074-
if ( count( $stock_string_arr ) < 1 ) {
1077+
if ( ! $product_ids ) {
10751078
return;
10761079
}
10771080

1078-
foreach ( $stock_string_arr as $edited_stock ) {
1079-
$product_id = (int) strtok( $edited_stock, '$' );
1080-
$product = wc_get_product( $product_id );
1081+
$lscwp_3rd_woocommerce = new self();
1082+
1083+
// The same product can appear in several edited columns; purge it once per request.
1084+
foreach ( array_keys( $product_ids ) as $product_id ) {
1085+
$product = wc_get_product( $product_id );
10811086

10821087
if ( empty( $product ) ) {
10831088
do_action( 'litespeed_debug', '3rd woo purge: ' . $product_id . ' not found.' );

0 commit comments

Comments
 (0)