In line 1174

$entity->revision_id != $item['revision_id']) {
      // A non-default revision is a referenced, so load this one.
      $entity = field_collection_item_revision_load($item['revision_id']);
    }

The code doesn't check for non null values of the item revision. When that happens it overwrites the entity to a null value.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ashalan created an issue. See original summary.

ashalan’s picture

Title: Getting entity value when revisioning is off returns empty field collection entity » When revisioning is off, field collection entity value renders null fields when editing
ashalan’s picture

Here is a patch to fix this

ashalan’s picture

Status: Active » Needs review
Chris Matthews’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll, +Needs rework

The patch in #3 does not apply to the latest 7.x-1.x-dev snapshot and may be too old to reroll, but I went ahead and tagged the issue accordingly.

Checking patch field_collection.module...
Hunk #1 succeeded at 1190 (offset 198 lines).
error: while searching for:
  elseif (isset($item['value'])) {
    // By default always load the default revision, so caches get used.
    $entity = field_collection_item_load($item['value']);
    if ($entity->revision_id != $item['revision_id']) {
      // A non-default revision is a referenced, so load this one.
      $entity = field_collection_item_revision_load($item['revision_id']);
    }

error: patch failed: field_collection.module:1170
error: field_collection.module: patch does not apply