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

WCS_Admin_Meta_Boxes->enqueue_styles_scripts() attempts to load non-subscription as subscription. #772

Open
2 tasks done
prettyboymp opened this issue Jan 28, 2025 · 0 comments · May be fixed by #776
Open
2 tasks done
Assignees
Labels
category: performance The issue/PR is related to performance. priority: high The issue/PR is high priority—it affects lots of customers substantially, but not critically. type: enhancement The issue is a request for an enhancement.

Comments

@prettyboymp
Copy link
Contributor

Describe the bug

WCS_Admin_Meta_Boxes->enqueue_styles_scripts() attempts to load a subscription on any admin page that has a global $post at the time of admin_enqueue_scripts executing, i.e. /wp-admin/edit.php or /wp-admin/edit.php?post_type=aw_workflow.

This doesn't appear to break anything specific as the default datastores do not return a data object, but does cause an extra query to be run on those pages when HPOS is enabled. I have not yet tested what occurs if HPOS is not enabled.

To Reproduce

  1. Enable HPOS.
  2. Install a query monitor.
  3. Visit admin posts listing page.
  4. Search for a query to get the order type of the first post of the listing page even though it is a post. E.g. SELECT id, type FROM wp_wc_orders WHERE id IN ( 1103554 )

Expected behavior

It isn't expected that the WCS_Admin_Meta_Boxes would attempt to load a non-subscription.

It is expected that the styles wouldn't attempt to be loaded for the metabox unless the metabox is actually added to the screen. Or at least verify that this is a screen that needs the subscription before attempting to load the subscription of the global $post.

Product impact

This is a core issue that affects both extensions, but the impact is minor.

  • Does this issue affect WooCommerce Subscriptions? yes/no/tbc, add issue ref
  • Does this issue affect WooCommerce Payments? yes/no/tbc, add issue ref
@prettyboymp prettyboymp added category: performance The issue/PR is related to performance. type: enhancement The issue is a request for an enhancement. priority: low The issue/PR is low priority—not many people are affected or there’s a workaround, etc. labels Jan 28, 2025
@james-allan james-allan self-assigned this Feb 3, 2025
@james-allan james-allan linked a pull request Feb 3, 2025 that will close this issue
4 tasks
@leonardola leonardola added priority: high The issue/PR is high priority—it affects lots of customers substantially, but not critically. and removed priority: low The issue/PR is low priority—not many people are affected or there’s a workaround, etc. labels Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: performance The issue/PR is related to performance. priority: high The issue/PR is high priority—it affects lots of customers substantially, but not critically. type: enhancement The issue is a request for an enhancement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants