Notice: Undefined property: stdClass::$bid in FieldCollectionItemEntity->fetchHostDetails()

Created on 18 October 2019, over 4 years ago
Updated 1 August 2023, 11 months ago

Hi, An error after upgrading from 7.x-1.0-beta13 when you save nodes, we are using php 7.2.19, ubuntu 18.04.2:

Notice: Undefined property: stdClass::$bid in FieldCollectionItemEntity->fetchHostDetails() (line 331 of /www/htdocs/sites/all/modules/contrib/field_collection/field_collection.entity.inc). 

The problem is the field collection is attached to multiple entities

Array
(
    [bean] => Array
        (
            [0] => features
        )

    [node] => Array
        (
            [0] => home_page
        )

)

so
$entity_type = key($field_info['bundles']);
returns the wrong entity for this field collection, with a bid rather than an nid....block not node

This works:

        if ($hostEntity) {
          $entity_type='';
          $bundle='';
          $key='';
          foreach(array_keys($field_info['bundles']) as $key){    
            if(isset($hostEntity->{$key})){
              //$entity_type = key($field_info['bundles']);
              $entity_type = $key;
              $bundle = current($field_info['bundles'][$entity_type]);
              $entity_info = entity_get_info($entity_type);
              $key = $entity_info['entity keys']['id'];
              $query->entityCondition('entity_type', $entity_type);
              $query->entityCondition('entity_id', $hostEntity->{$key});
            }
          }
          $query->entityCondition('bundle', $bundle);
          if (isset($entity_info['entity keys']['language'])) {
            $query->propertyCondition('language', $hostEntity->language);
          }
        }

πŸ› Bug report
Status

RTBC

Version

1.0

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom StephenRobinson

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.69.0 2024