Commit cedb1d3e authored by jmuzz's avatar jmuzz
Browse files

Issue #2125017: Fixed field collection items being created as archived when...

Issue #2125017: Fixed field collection items being created as archived when made with a new node revision.
parent 19725275
......@@ -953,6 +953,13 @@ function field_collection_field_update($host_entity_type, $host_entity, $field,
// If the host entity is saved as new revision, do the same for the item.
if (!empty($host_entity->revision)) {
$entity->revision = TRUE;
// Without this cache clear entity_revision_is_default will
// incorrectly return false here when creating a new published revision
if (!isset($cleared_host_entity_cache)) {
list($entity_id) = entity_extract_ids($host_entity_type, $host_entity);
$cleared_host_entity_cache = true;
$is_default = entity_revision_is_default($host_entity_type, $host_entity);
// If an entity type does not support saving non-default entities,
// assume it will be saved as default.
......@@ -113,6 +113,10 @@ class FieldCollectionBasicTestCase extends DrupalWebTestCase {
// Test Revisions.
list ($node, $item) = $this->createNodeWithFieldCollection();
$entity2 = entity_create('field_collection_item', array('field_name' => $this->field_name));
$node->{$this->field_name}[LANGUAGE_NONE][] = array('entity' => $entity2);
$this->assertEqual($entity2->archived, FALSE, 'New field collection item with new content revision is not archived.');
// Test saving a new revision of a node.
$node->revision = TRUE;
......@@ -120,6 +124,9 @@ class FieldCollectionBasicTestCase extends DrupalWebTestCase {
$item_updated = field_collection_item_load($node->{$this->field_name}[LANGUAGE_NONE][0]['value']);
$this->assertNotEqual($item->revision_id, $item_updated->revision_id, 'Creating a new host entity revision creates a new field collection revision.');
// Test saving a new revision with a new field collection item.
$node->revision = TRUE;
// Test saving the node without creating a new revision.
$item = $item_updated;
$node->revision = FALSE;
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