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

Polyfill wc_is_running_from_async_action_scheduler(). #5379

Merged
merged 1 commit into from
Oct 14, 2020

Conversation

jeffstieler
Copy link
Contributor

Supports WC versions < 4.0.0.

Fixes #5378.

This PR introduces a polyfill for the wc_is_running_from_async_action_scheduler() function for stores running WooCommerce < 4.0.0.

The call to wc_is_running_from_async_action_scheduler() was introduced in this PR. Curiously, the PHP 5.6 + WC 3.8 build did not fail because this code path does not get executed by any tests.

Detailed test instructions:

  • On main
  • Install WC 3.9.3 on a test store
  • Load the WP dashboard
  • Verify PHP Fatal error occurs
  • Switch to this branch
  • Load the WP dashboard
  • Verify no PHP Fatal error occurs

Changelog Note:

Fix: use of WC 4.0+ function.

Copy link
Contributor

@octaedro octaedro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @jeffstieler for this fix. Code looks good and I tried this on an ephemeral site and it tested well.
Good job :shipit:

@jeffstieler jeffstieler merged commit 99ec6a1 into main Oct 14, 2020
@jeffstieler jeffstieler deleted the fix/5378-undefined-function branch October 14, 2020 13:46
@octaedro
Copy link
Contributor

@jeffstieler Probably it's not related to this issue, but using this branch on an ephemeral site I saw this Notice in the Home screen

Notice: register_rest_route was called incorrectly. The REST API route definition for wc/store/cart is missing the required permission_callback argument. For REST API routes that are intended to be public, use __return_true as the permission callback. Please see Debugging in WordPress for more information. (This message was added in version 5.5.0.) in /srv/users/user98f1e275/apps/user98f1e275/public/wp-includes/functions.php on line 5225

Notice: register_rest_route was called incorrectly. The REST API route definition for wc/store/cart/items/(?P[\w-]{32}) is missing the required permission_callback argument. For REST API routes that are intended to be public, use __return_true as the permission callback. Please see Debugging in WordPress for more information. (This message was added in version 5.5.0.) in /srv/users/user98f1e275/apps/user98f1e275/public/wp-includes/functions.php on line 5225

Notice: register_rest_route was called incorrectly. The REST API route definition for wc/store/products/(?P[\d]+) is missing the required permission_callback argument. For REST API routes that are intended to be public, use __return_true as the permission callback. Please see Debugging in WordPress for more information. (This message was added in version 5.5.0.) in /srv/users/user98f1e275/apps/user98f1e275/public/wp-includes/functions.php on line 5225

Notice: register_rest_route was called incorrectly. The REST API route definition for wc/store/products/collection-data is missing the required permission_callback argument. For REST API routes that are intended to be public, use __return_true as the permission callback. Please see Debugging in WordPress for more information. (This message was added in version 5.5.0.) in /srv/users/user98f1e275/apps/user98f1e275/public/wp-includes/functions.php on line 5225

@jeffstieler
Copy link
Contributor Author

@octaedro those route definitions are in the Blocks repo. I believe these warnings stem from WP 5.1.

jeffstieler added a commit that referenced this pull request Oct 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug The issue is a confirmed bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fatal erroring calling "wc_is_running_from_async_action_scheduler" with WC <4.0.0
3 participants