In field_collection_field_update() the entity's default_revision is only set to match the host entity's if the host is the default also. For the case where the host entity is NOT the default (ie revisions), this can result in incorrect saving of the field collection item with default_revision set to TRUE if it was loaded with default_revision set to TRUE.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

recrit’s picture

Status: Active » Needs review
FileSize
931 bytes

The attached patch reworks the code that sets default_revision to always match the host entity's default.

Status: Needs review » Needs work
dealancer’s picture

recrit’s picture

Status: Needs work » Closed (duplicate)

Field collection saving summary:
#2274953: Default revision is incorrectly set when host entity is NOT default- This patch turned out not to be needed since the combination of patches below ensured proper revision saving with workbench moderation.

Field collection patches:
* #1822844: Notice: Undefined index: revision_id in field_collection_field_get_entity() (line 1586 of field_collection/field_collection.modu - fixed field_collection_field_get_entity() to load the correct revision.

Workbench moderation patches:
* #1084436: doesn't seem to handle file attachments at all - removes un-needed field_attach_update().
* #1963992: Don't use $reset flag with node_load() - fixes wb moderation from clearing the entity cache when saving the live revision.

a.milkovsky’s picture

Assigned: Unassigned » a.milkovsky
Status: Closed (duplicate) » Active

Related issues do not duplicate current issue:
https://www.drupal.org/node/2125017 - about archive attribute
https://www.drupal.org/node/1822844 - notice in field_collection_field_get_entity().
Other links are not relate as they are about the Workbench module.

There is no issue about default_revision attribute or field_collection_field_update() function.

a.milkovsky’s picture

Status: Active » Needs review
FileSize
477 bytes

We should simply set $entity->default_revision = FALSE; if host entity is not default revision on update.
We don't need to change archived attribute, as it is designed for other purposes.

a.milkovsky’s picture

Assigned: a.milkovsky » Unassigned
fago’s picture

Status: Needs review » Fixed

Thanks, committed #7.

  • a.milkovsky authored c07b3ec on 7.x-1.x
    Issue #2274953 by a.milkovsky, recrit: Default revision is incorrectly...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.