Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Cart route being loaded in editor #8244

Closed
kimmenbert opened this issue Jan 19, 2023 · 2 comments · Fixed by #8413
Closed

Cart route being loaded in editor #8244

kimmenbert opened this issue Jan 19, 2023 · 2 comments · Fixed by #8413
Assignees
Labels
block: cart Issues related to the cart block. focus: performance The issue/PR is related to performance. type: bug The issue/PR concerns a confirmed bug.

Comments

@kimmenbert
Copy link

kimmenbert commented Jan 19, 2023

Describe the bug

Even without any WooCommerce blocks in content, the speed of the editor seems to be affected by WooCommerce blocks.
On a project I'm working on, I hooked into woocommerce_check_cart_items. I never expected that using that filter would be triggered back-end.

This makes me wonder. How much non-needed logic is processed in the editor. Worst case, will editor performance now be affected by the number of products in your cart session?

To reproduce

  1. Log in to admin, go to the edit screen of any page / post

  2. Add this piece of code to your functions.php / a custom plugin

function thing_happens_in_editor() {
  die( 'Why' );
}
add_action( 'woocommerce_check_cart_items', 'thing_happens_in_editor', 1 );
  1. Reload page, see "Why" message

Expected behavior

I would not expect this logic to affect the editor, at least not when the editor does not even contain any WC block

Environment

WordPress (please complete the following information):

  • WordPress version: 6.1.1
  • WooCommerce version: 7.3.0
@kimmenbert kimmenbert added the type: bug The issue/PR concerns a confirmed bug. label Jan 19, 2023
@senadir
Copy link
Member

senadir commented Jan 20, 2023

Thank you for letting us know @kimmenbert! Cart session should not be reached during render in the editor, we use a fully mocked up cart to avoid that, there may be a regression that caused this. I will reword the issue title to reflect that.

@senadir senadir changed the title Frontend expected code runs backend Cart route being loaded in editor Jan 20, 2023
@nielslange nielslange added the block: cart Issues related to the cart block. label Jan 23, 2023
@ralucaStan ralucaStan added the focus: performance The issue/PR is related to performance. label Jan 27, 2023
@mikejolley mikejolley self-assigned this Feb 13, 2023
@mikejolley
Copy link
Member

Triggered by the "All Products" block for some reason. Investigating.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
block: cart Issues related to the cart block. focus: performance The issue/PR is related to performance. type: bug The issue/PR concerns a confirmed bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants