Ensure node isn't new before attempting to load groups

Created on 25 May 2019, over 5 years ago
Updated 13 March 2024, 8 months ago

This code:

 public function build() {
    // Get the associated group content for the current node.
    $node = $this->getContextValue('node');
    if ($node) {
      $group_contents = GroupContent::loadByEntity($node);

fails when on a node/add/whatever page because it gets an unsaved node object. This results in the error:

Drupal\Core\Entity\EntityStorageException: Cannot load GroupContent entities for an unsaved entity. in Drupal\group\Entity\Storage\GroupContentStorage->loadByEntity()

πŸ› Bug report
Status

RTBC

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States michelle Wisconsin, USA

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024