I have a content type (Homepage) which has 3 different field collection embeded and 2 of them has another field collection inside. So its nested field collection issue. I am following Entity Translation for my D7 multilingual site. When I tried to translate the content I got this error
EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line of 7670 includes/common.inc).
Line 7663
if (!isset($entity->{$info['entity keys']['bundle']}) || $entity->{$info['entity keys']['bundle']} === '') {
throw new EntityMalformedException(t('Missing bundle property on entity of type @entity_type.', array('@entity_type' => $entity_type)));
}
I found that the system is throwing an exception in that line is something is wrong or blank.
I have added this code before line 7662
dpm($info['entity keys']['bundle']."=====> ".$entity->{$info['entity keys']['bundle']});
and found that one of "$entity->{$info['entity keys']['bundle']}" is blank and its not returning any name of the content type. It should say
type -> homepage like any other line has. I have added screenshot.
Comment | File | Size | Author |
---|---|---|---|
translation_error.gif | 429.72 KB | ghalenir |
Comments
Comment #1
ghalenir CreditAttribution: ghalenir commentedI am debugging my project with Netbeans 7.3 and xdebug and found that entity information is blank when I added $entity in a watch in this function.
/sites/all/modules/contrib/entity_translation/includes/translation.handler.inc
/**
* @see EntityTranslationHandlerInterface::setEntity()
*/
public function setEntity($entity) {
}
FieldCollectionItemEntity object {
fieldInfo => null
hostEntity => null
hostEntityId => null
hostEntityRevisionId => null
hostEntityType => null
langcode => (string) und
item_id => null
revision_id => null
field_name => (string) field_homepage_lead_slider
default_revision => (bool) true
archived => (bool) false
entityType => (string) field_collection_item
entityInfo => array(24) (
[label] => (string) Field collection item
[label callback] => (string) entity_class_label
[uri callback] => (string) entity_class_uri
[entity class] => (string) FieldCollectionItemEntity
[controller class] => (string) EntityAPIController
[base table] => (string) field_collection_item
[revision table] => (string) field_collection_item_revision
[fieldable] => (bool) true
[redirect] => (bool) false
[entity keys] => array(4) (
[id] => (string) item_id
[revision] => (string) revision_id
[bundle] => (string) field_name
[translations] => (string) translations
)
that may be also a reason. There 3 different field collection with unlimited option. None of those field collection fields are required and I didn't fill out all the field collection fields and that's why their properties may be blank. But I need to know how to ignore those blank fields and save the form with little fields translated.
Comment #2
Kristen PolI've noticed these types of errors in a single-language site. Here is another issue with that exception due to different reasons:
#1778572: EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7562
and these posts have some more links:
http://stackoverflow.com/questions/10023653/getting-entity-malformed-exc...
http://www.zyxware.com/articles/3331/solved-drupal-errors-entitymalforme...
Comment #3
Kristen PolThe Field Collection queue has some issues about this error... e.g.
#1686376: EntityMalformedException: when editing a collection from node view when collection has nested collections
Comment #4
Kristen PolChanging to support request for now... not sure if this is an ET issue or FC issue or something else entirely.
Comment #5
ghalenir CreditAttribution: ghalenir commentedI can edit and save the content in English language which is a default language setting. I get this error only when I try to translate the content and save it. It was working fine before I enable entity translation.
Comment #6
Kristen PolAh... then perhaps it is an ET issue. Someone posted that this patch:
#1865244-7: Allow multiple translation handlers on the same form
Helped resolve a similar exception. Perhaps update to latest dev (test again if you aren't running that) and apply that patch to see if it does anything.
Comment #7
ghalenir CreditAttribution: ghalenir commentedI went through entity translation module and found that its not passing entity_type property to setEntity function which is fine.
entity_translation.module
function entity_translation_language($entity_type, $entity) {
$langcode = $handler->getLanguage();
//old code
$handler->setEntity($entity);
//I added
// $entity_type = 'field_collection_item'
$handler->setEntity($entity,$entity_type);
}
But when you try to get the entity type in this function
includes/translation.handler.inc
public function setEntity($entity,$entity_type=NULL) {
if($entity_type != NULL){
// I added
$entity_type = 'field_collection_item'
list($this->entityId, , $this->bundle) = entity_extract_ids($entity_type, $this->entity);
}
else
{
// Update bundle and entity id properties.
// old code
$this->entity_type = 'bean'
list($this->entityId, , $this->bundle) = entity_extract_ids($this->entityType, $this->entity);
}
}
After I changed the above code somehow its working but still when you try to add more item with "Add More Item" button for FC then my FC content goes blank and it happens only for translated content. It doesn't happen when you try to edit the English content.
I don't know if I added right code or not.
Comment #8
Kristen PolAre you able to reproduce in a totally different environment? i.e. fresh install, ET, FC and nothing else installed?
Comment #9
ghalenir CreditAttribution: ghalenir commentedI have added couple of patches for both ET and FC modules. So there will be problem if I don't use Dev versions of FC and ET and Beans module. Can you recommend which version should I use so that I will try to install fresh D7 installation with ET, FC and Beans module.
Comment #10
Kristen PolI would try the latest dev for all of them.
Comment #11
ghalenir CreditAttribution: ghalenir commentedIs it safe to use those dev versions of FC, ET for live site ?
Comment #12
Kristen PolIf they work as expected, then it should be fine. I use dev versions of modules regularly. But, make sure to QA things well.
Comment #13
plachNothing more to add to what Kristen said :)
Comment #15
FrancewhoaConfirming this bug can be reproduce with 7.x-1.0-beta4
We have not yet tried the latest dev version. That bug is maybe related to Beta 4 introducing some database schema changes at https://www.drupal.org/node/2412615 We have not yet tried that either.
Comment #16
FrancewhoaSteps to reproduce this bug
/admin/config/regional/entity_translation
If you redo all the above steps but uncheck "Comment" option the error message is gone