Commit 1b1d38dd authored by istryker's avatar istryker Committed by Ra Mänd
Browse files

Issue #3091188 by iStryker: Field Collection stop working

parent b3dc9398
<?php <?php
/** /**
* @file * @file
* Module implementing field collection field type. * Module implementing field collection field type.
...@@ -963,7 +964,7 @@ function field_collection_entity_preload($entities, $langcode, &$items, $fields) ...@@ -963,7 +964,7 @@ function field_collection_entity_preload($entities, $langcode, &$items, $fields)
static $local_entity_cache = array(); static $local_entity_cache = array();
$fc_ids = array(); $fc_ids = array();
$new_items = array();
// Collect every possible term attached to any of the fieldable entities. // Collect every possible term attached to any of the fieldable entities.
foreach ($entities as $id => $entity) { foreach ($entities as $id => $entity) {
foreach ($items[$id] as $delta => $item) { foreach ($items[$id] as $delta => $item) {
...@@ -982,6 +983,7 @@ function field_collection_entity_preload($entities, $langcode, &$items, $fields) ...@@ -982,6 +983,7 @@ function field_collection_entity_preload($entities, $langcode, &$items, $fields)
if ($fc_ids) { if ($fc_ids) {
$new_entities = array(); $new_entities = array();
$terms = field_collection_item_load_multiple($fc_ids); $terms = field_collection_item_load_multiple($fc_ids);
$new_items == $items;
// Iterate through the fieldable entities again to attach the loaded // Iterate through the fieldable entities again to attach the loaded
// field collection data. // field collection data.
...@@ -1002,7 +1004,7 @@ function field_collection_entity_preload($entities, $langcode, &$items, $fields) ...@@ -1002,7 +1004,7 @@ function field_collection_entity_preload($entities, $langcode, &$items, $fields)
$field_data = $e->$field_name; $field_data = $e->$field_name;
if (isset($field_data[$langcode])) { if (isset($field_data[$langcode])) {
$new_entities[$e->item_id] = $e->item_id; $new_entities[$e->item_id] = $e->item_id;
$items[$e->item_id] = $field_data[$langcode]; $new_items[$e->item_id] = $field_data[$langcode];
} }
} }
} }
...@@ -1010,18 +1012,17 @@ function field_collection_entity_preload($entities, $langcode, &$items, $fields) ...@@ -1010,18 +1012,17 @@ function field_collection_entity_preload($entities, $langcode, &$items, $fields)
// Otherwise, unset the instance value, since the field colletion entity // Otherwise, unset the instance value, since the field colletion entity
// does not exist. // does not exist.
else { else {
unset($items[$id][$delta]); unset($new_items[$id][$delta]);
$rekey = TRUE; $rekey = TRUE;
} }
} }
if ($rekey) { if ($rekey) {
// Rekey the items array. // Rekey the items array.
$items[$id] = array_values($items[$id]); $new_items[$id] = array_values($new_items[$id]);
} }
} }
field_collection_entity_preload($new_entities, $langcode, $new_items, $fields);
field_collection_entity_preload($new_entities, $langcode, $items, $fields);
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment