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

Evaluate conditionally intializing REST APIs #8797

Closed
kalessil opened this issue May 8, 2024 · 0 comments · Fixed by #8805
Closed

Evaluate conditionally intializing REST APIs #8797

kalessil opened this issue May 8, 2024 · 0 comments · Fixed by #8805
Assignees
Labels
focus: architecture Product architecture and engineering best practices

Comments

@kalessil
Copy link
Contributor

kalessil commented May 8, 2024

Description

We have at least two places where the rest initialization happens (add_action( 'rest_api_init', ... );).
To avoid unnecessary runtime operations, the initialization can be conditional - can be a wrapping if-statement around adding the hook or inside the invoked methods.

Note: the conditional ideas are

  • relying to WC()->is_rest_api_request()
  • match the rest URL to include @^/wc/v3/payments/.+@, that'll guard our rest APIs from loading in the wrong context.
  • relying to get_current_screen()
  • relying to doing_action( 'woocommerce_admin_shared_settings' )

Acceptance criteria

  • We evaluate that there is no higher-level logic which does it already
  • CI checks pass after any implemented changes

Additional context

  • The side-quest discovery of p1715098461138369-slack-CGGCLBN58
  • Ideally, we don't need such checks, but from the linked context, we have this code fragment and want to explore if we can skip this context for loading our rest
@kalessil kalessil self-assigned this May 8, 2024
@FangedParakeet FangedParakeet added the focus: architecture Product architecture and engineering best practices label May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
focus: architecture Product architecture and engineering best practices
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants