Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Product sorting in WooCommerce backend does not work when WP Rocket is active #5984

Closed
4 tasks
camilamadronero opened this issue Jun 16, 2023 · 2 comments · Fixed by #5993
Closed
4 tasks
Assignees
Labels
3rd party compatibility Issues related to 3rd party compatibility like theme, plugin or hosting effort: [XS] < 1 day of estimated development time priority: high Issues which should be resolved as quickly as possible type: enhancement Improvements that slightly enhance existing functionality and are fast to implement
Milestone

Comments

@camilamadronero
Copy link

camilamadronero commented Jun 16, 2023

Before submitting an issue please check that you’ve completed the following steps:

  • Made sure you’re on the latest version - Y
  • Used the search feature to ensure that the bug hasn’t been reported before - Y

Describe the bug
It's not possible to sort products within WooCommerce products page. Instead, you can see 524 error in the console.

To Reproduce
Steps to reproduce the behavior:

  1. In a site with WooCommerce, WP Rocket and hosted on Cloudways (not sure what other requirements may be)
  2. Go to WooCommerce product page
  3. Click on a product's checkbox to try to sort it
  4. The checkbox will show a loading icon that never goes away, and sorting won't be possible

Expected behavior
Product sorting should work as expected

Screenshots
Product sorting error with the loading icon stuck: https://capture.dropbox.com/drH0ISsNLOK4zhCb (@markonikolic985 screenshot)

Additional context
From @engahmeds3ed:

the problem starts in WooCommerce exactly here
they get all posts (in this site the number of those posts are +500) with their menu order and loop on them and after updating their menu_order , they clean post cache here and then set the main product menu_order and also clean post cache here
so this is taking lots of time to update and clear post cache.
My temporary fix is to disable cleaning post cache inside this method only.

add_action( 'wp_ajax_woocommerce_product_ordering', function(){
	global $_wp_suspend_cache_invalidation;
	$_wp_suspend_cache_invalidation = true;
}, 9 );

add_action( 'wp_ajax_woocommerce_product_ordering', function(){
	global $_wp_suspend_cache_invalidation;
	$_wp_suspend_cache_invalidation = false;
}, 11 );

you can know more about the feature here:
woocommerce/woocommerce#31389

Also:

both sites are on cloudways

Slack Dev-team escalation thread: https://wp-media.slack.com/archives/C056ZJMHG0P/p1685433858614039
Tickets: https://secure.helpscout.net/conversation/2237699192/419020?folderId=424682 and https://secure.helpscout.net/conversation/2254739596/421844/

Backlog Grooming (for WP Media dev team use only)

  • Reproduce the problem
  • Identify the root cause
  • Scope a solution
  • Estimate the effort
@piotrbak piotrbak added type: enhancement Improvements that slightly enhance existing functionality and are fast to implement 3rd party compatibility Issues related to 3rd party compatibility like theme, plugin or hosting priority: high Issues which should be resolved as quickly as possible needs: grooming labels Jun 18, 2023
@piotrbak
Copy link
Contributor

Acceptance Criteria:

  1. WP Rocket's cache should not be cleared when sorting products in the backend
  2. The functionality added by WooCommerce in the WooCommerce Category Product sorting not working only on Atomic sites woocommerce/woocommerce#31389 should be preserved.

@jeawhanlee jeawhanlee added GROOMING IN PROGRESS Use this label when the issue is currently being groomed. and removed needs: grooming labels Jun 19, 2023
@jeawhanlee
Copy link
Contributor

Reproduce the problem ✅

Did not reproduce the issue.

Identify the root cause ✅

Like @engahmeds3ed WC clears posts cache during the product sorting process by calling the function - clean_post_cache which has the clean_post_cache action in it. Then we are hooking to this action to clear post cache when required here so whenever WC clears post and clean_post_cache is fired, rocket_clean_post will run.

Scope a solution ✅

We can add a new filter in

function rocket_clean_post( $post_id, $post = null ) {
and return early

if ( ! apply_filters( 'rocket_allow_clean_post', true ) ) {
  return false;
}

Then we will use wp_ajax_woocommerce_product_ordering hook in ThirdParty\Plugins\Ecommerce::WooCommerceSubscriber with a call back function that retuns false for the new filter - rocket_allow_clean_post.

public function stop_post_cache_clearing() {
  add_filter( 'rocket_allow_clean_post', [ $this, 'return_true' ] );
}

Estimate the effort ✅
[XS]

@jeawhanlee jeawhanlee added effort: [XS] < 1 day of estimated development time and removed GROOMING IN PROGRESS Use this label when the issue is currently being groomed. labels Jun 19, 2023
@jeawhanlee jeawhanlee self-assigned this Jun 19, 2023
@piotrbak piotrbak added this to the 3.14.2 milestone Jul 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3rd party compatibility Issues related to 3rd party compatibility like theme, plugin or hosting effort: [XS] < 1 day of estimated development time priority: high Issues which should be resolved as quickly as possible type: enhancement Improvements that slightly enhance existing functionality and are fast to implement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants