Non-strict comparison when checking if product is in current store can cause a fatal error

Created on 9 February 2023, almost 2 years ago
Updated 10 February 2023, almost 2 years ago

Describe your bug or feature request.

I have started getting this error:

Fatal error: Nesting level too deep - recursive dependency? in /opt/drupal/web/modules/contrib/commerce/modules/store/src/SelectStoreTrait.php on line 46

Looking at the offending line, in_array is being used to check if the current store is in the array of stores the product is in. Because in_array is non-strict by default, this means every property on the store is compared to every other property, which seems inefficient, but also means any recursion will cause issues.

To avoid this issue the comparison should be strict, which we can achieve by passing true to the third parameter of in_array.

🐛 Bug report
Status

Fixed

Version

2.0

Component

Store

Created by

🇳🇿New Zealand fraserthompson Dunedin, New Zealand

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

Comments & Activities

Production build 0.71.5 2024