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.

CommentFileSizeAuthor
translation_error.gif429.72 KBghalenir
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ghalenir’s picture

I 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.

Kristen Pol’s picture

Kristen Pol’s picture

Kristen Pol’s picture

Category: bug » support

Changing to support request for now... not sure if this is an ET issue or FC issue or something else entirely.

ghalenir’s picture

I 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.

Kristen Pol’s picture

Ah... 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.

ghalenir’s picture

I 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.

Kristen Pol’s picture

Are you able to reproduce in a totally different environment? i.e. fresh install, ET, FC and nothing else installed?

ghalenir’s picture

I 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.

Kristen Pol’s picture

I would try the latest dev for all of them.

ghalenir’s picture

Is it safe to use those dev versions of FC, ET for live site ?

Kristen Pol’s picture

If they work as expected, then it should be fine. I use dev versions of modules regularly. But, make sure to QA things well.

plach’s picture

Status: Active » Fixed

Nothing more to add to what Kristen said :)

Status: Fixed » Closed (fixed)

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

Francewhoa’s picture

Version: 7.x-1.0-beta2 » 7.x-1.0-beta4
Category: Support request » Bug report
Issue summary: View changes

Confirming this bug can be reproduce with 7.x-1.0-beta4

EntityMalformedException: Missing bundle property on entity of type comment. in entity_extract_ids() (line 7766 of [***]/includes/common.inc).

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.

Francewhoa’s picture

Steps to reproduce this bug

  1. Fresh Drupal 7 site. Empty site. No data migrated.
  2. Using entity_translation 7.x-1.0-beta4
  3. Activate revision for all content types
  4. Go to /admin/config/regional/entity_translation
  5. Expand "Translatable entity types" section
  6. Check "Comment" option
  7. Save
  8. Clear all caches
  9. Try to post a comment. Drupal returns the following error message

EntityMalformedException: Missing bundle property on entity of type comment. in entity_extract_ids() (line 7766 of [***]/includes/common.inc).

If you redo all the above steps but uncheck "Comment" option the error message is gone