Update stripping of null variant options - Deprecated function: strlen(): Passing null to parameter #1

Created on 7 March 2024, 4 months ago

Problem/Motivation

With the release of PHP 8.1, strlen() has depreciated accepting null values, therefore this error occurs:
Deprecated function: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in Drupal\shopify\Entity\ShopifyProductVariant->getFormattedOptions() (line 131 of /app/site/modules/contrib/shopify/src/Entity/ShopifyProductVariant.php)

Steps to reproduce

Any Drupal version.
Running a site using PHP8.1+
1. Install module
2. Configure and setup the module with shopify
3. View a product that has options (variants)
4. Select an option
5. An error will display or Check the Recent log messages

Proposed resolution

Update the getFormattedOptions function to not use array_filter strlen() callback for the purpose of stripping null values (but maintaining 0 values) replace with array diff filtering.

The issue was caused during this fix: https://www.drupal.org/project/shopify/issues/2867578 β†’

πŸ› Bug report
Status

Active

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom nathankg

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024