Commit 280de245 authored by jameswilliams's avatar jameswilliams Committed by Joel Muzzerall
Browse files

Issue #2759157 by james.williams, nadavoid, drilix: Orphaned field collections...

Issue #2759157 by james.williams, nadavoid, drilix: Orphaned field collections no longer break update 7008
parent 0918975a
......@@ -373,11 +373,23 @@ function field_collection_update_7008() {
}
}
if (count($results)) {
$orphans = array();
$ids = array_keys($results);
$field_collection_items = entity_load('field_collection_item', $ids);
foreach ($field_collection_items as $item) {
$item->copyTranslations(LANGUAGE_NONE);
$item->save();
/** @var FieldCollectionItemEntity $item */
if ($item->hostEntity()) {
$item->copyTranslations(LANGUAGE_NONE);
$item->save(TRUE);
}
else {
$orphans[] = $item->identifier();
}
}
if ($orphans) {
$count = count($orphans);
entity_delete_multiple('field_collection_item', $orphans);
drupal_set_message("Deleted $count orphaned field collection items.");
}
}
}
Supports Markdown
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