From 43097f4b2c03989a3677c096230765d7e5c70ddc Mon Sep 17 00:00:00 2001 From: Micah Wittman Date: Wed, 8 Oct 2025 14:02:57 -0300 Subject: [PATCH] Product details item groups read property on null fix $groups->getFirst() can return null which was not guarded against. If null there are zero groups. --- Store/admin/components/Product/Details.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Store/admin/components/Product/Details.php b/Store/admin/components/Product/Details.php index 76ad226b..b56b0823 100644 --- a/Store/admin/components/Product/Details.php +++ b/Store/admin/components/Product/Details.php @@ -1125,13 +1125,17 @@ private function buildItemGroups() $groups = $this->queryItemGroups(); $has_items = (count($groups) > 0); - // if there is one row and the groupnum is 0 then there are no + // if there is now rows or one row and the groupnum is 0 then there are no // item_groups with items in them for this product. If $groups has 0 // elements, there are no items - if (count($groups) == 1 && $groups->getFirst()->item_group == 0) { + $first_group = $groups->getFirst(); + if ( + $first_group === null || + (count($groups) === 1 && $first_group->item_group === 0) + ) { $num_groups = 0; - } elseif ($groups->getFirst()->item_group == 0) { + } elseif ($first_group->item_group === 0) { $num_groups = count($groups) - 1; } else { $num_groups = count($groups);