Hi,

I set up group for custom node type and I got this error message when opening a node.

Notice: Trying to access array offset on value of type null in Drupal\social_group\SocialGroupHelperService->getGroupFromEntity() (line 65 of profiles/contrib/social/modules/social_features/social_group/src/SocialGroupHelperService.php).

This is the line of code that cause issue. Sometimes the $this->cache is null, so I got this issue.

if ($read_cache && is_array($this->cache[$cache_type]) && isset($this->cache[$cache_type][$cache_id])) {
      return $this->cache[$cache_type][$cache_id];
}

My solution is: check null on $this->cache

if ($read_cache && isset($this->cache)&& is_array($this->cache[$cache_type]) && isset($this->cache[$cache_type][$cache_id])) {
      return $this->cache[$cache_type][$cache_id];
}

Comments

howto created an issue. See original summary.

jummonk’s picture

Version: 8.x-8.3 » 8.x-8.9
Component: Groups » Code (back-end)
Assigned: Unassigned » jummonk
StatusFileSize
new716 bytes

You only need to check existence of the tested variable. See patch.

norman.lol’s picture

Assigned: jummonk » Unassigned
Status: Active » Needs review
StatusFileSize
new756 bytes

Updated patch to include array check and updated indentation.

norman.lol’s picture

I needed the patch from the other issue as well. It's all related to the situation where you have no hero image.

tbsiqueira’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.