Problem/Motivation
I am getting a PHP notice for undefined object property "original" when saving a field collection using $fc_item->save(TRUE) where $skip_host_save = TRUE.
Notice: Trying to get property of non-object in EntityAPIController->saveRevision() (line 520 of /entity/includes/entity.controller.inc).
This calls entity_get_controller($this->entityType)->save($this) and passes my entity object (seen below) to saveRevision($entity) in entity_controller.inc.
It is reporting the error on the following line:
$update_default_revision = $entity->{$this->defaultRevisionKey} && $entity->{$this->revisionKey} != $entity->original->{$this->revisionKey}
I cannot use the entity_meta_wrapper as it does not provide the $skip_host_save argument. Therefore I modify field collection properties in code as shown below and call save method directly on the field collection entity object.
$fc_item->{$field_name}[LANGUAGE_NONE][0]['value'] = $field_value;
$fc_item->save(TRUE);
In this senario $entity->original does not exist in certain cases and then we run into this issue.
Proposed resolution
Determine if either of the below are required, or both.
- if field_collection should force inclusion of
$entity->originalobject - if a check should be provided in entity.controller.inc
Remaining tasks
- if field_collection should force inclusion of
$entity->originalobject if a check should be provided in entity.controller.inc- patch provided
User interface changes
N/A
API changes
N/A
Data model changes
N/A
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | entity-entity-original-missing-2602346-4-d8.patch | 1.06 KB | mccrodp |
Comments
Comment #2
mccrodp commentedComment #3
mccrodp commentedComment #4
mccrodp commentedAdding a patch to check for existence of
$entity->originalproperty.Changed:
To:
Comment #5
mccrodp commentedComment #6
chris matthews commentedThe 3 year old patch in #4 to entity.controller.inc applied cleanly to the latest entity 7.x-1.x-dev and (if still relevant) needs review.