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];
}
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | 3137531-3.patch | 756 bytes | norman.lol |
| #2 | social-error-message-when-opening-node-3137531-1.patch | 716 bytes | jummonk |
Comments
Comment #2
jummonk commentedYou only need to check existence of the tested variable. See patch.
Comment #3
norman.lolUpdated patch to include array check and updated indentation.
Comment #4
norman.lolI needed the patch from the other issue as well. It's all related to the situation where you have no hero image.
Comment #5
tbsiqueira