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

Fix product visibility evaluation in PHP 8 #2566

Merged
merged 1 commit into from
Jan 25, 2022

Conversation

felipeelia
Copy link
Member

Description of the Change

Currently, InstantResults::apply_product_visibility() calls wc_get_product_visibility_term_ids() and uses $product_visibility_terms['exclude-from-search'] as an array, when it actually is a term id. In PHP 8, that results in a fatal error:

PHP Fatal error: Uncaught Error: Cannot use a scalar value as an array in /var/www/html/wp-content/plugins/elasticpress/includes/classes/Feature/InstantResults/InstantResults.php:479

This PR addresses that, forcing the result to be an array.

Verification Process

  • Spin up a local env using PHP 8
  • Install WooCommerce and enable "Hide out of stock items from the catalog" (/wp-admin/admin.php?page=wc-settings&tab=products&section=inventory)
  • Install the EP Proxy and activate the Instant Results feature
  • See the sync failing

Changelog Entry

Fixed the sync page when WC's "hide out of stock items" and Instant Results are both enabled.

@felipeelia felipeelia added this to the 4.0.0 (beta 2) milestone Jan 25, 2022
@felipeelia felipeelia self-assigned this Jan 25, 2022
@felipeelia felipeelia merged commit 791344c into 4.x.x Jan 25, 2022
@felipeelia felipeelia deleted the fix/prod-visibility-php-8 branch January 25, 2022 19:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant