We are using this fantastic module with embedded display - the development version actually. After we started to fill our entities with data we got this exception when we view this entity:

EntityMalformedException: Missing bundle property on entity of type field_collection_item. entity_extract_ids() függvényben (/home/x/public_html/includes/common.inc 7390 sor).

After when this error appears the entity is not editable because of this error.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jdufaur’s picture

Hello,

I have the same error.
EntityMalformedException: Missing bundle property on entity of type field_collection_item. in entity_extract_ids() (line 7389 of D:\Sites\Drupalspace\includes\common.inc).

mauriziopinotti’s picture

same here

Denes.Szabo’s picture

I patched my version with this issue's latest patch: http://drupal.org/node/1186826 - It seems ok now.

I think the problem is about deleting item from the collection. I had a field value that not existed in the field_collection table. After this patch we have not got a new exception. (fingers crossed, of course! :))

Remon’s picture

Subscribe, even the patch mentioned above doesn't fix it for me.

grahamtk’s picture

Is it so that this may make a db of objects / entities stale, so for this patch to fix anything one should load and save every object that might have turned inconsistent?

sachbearbeiter’s picture

sub

Bevan’s picture

This appears to be related to #1269750: Exporting a Field Collection field with a default value to Features leads to a PHP parse error.

Are you using features to store the configuration for the field collection and/or it's field/instance? What happens if you disable any defaults for the field collection?

bforchhammer’s picture

I get the same error when I try to view a field collection. All relevant field collections and fields are in the database though, so not sure this is related to features...

Can't say whether it's related but the eva module spits out a notice before the EntityMalformedException is thrown:

    Notice: Undefined variable: entity in _eva_extract_entity_from_build() (line 148 of C:\wamp\www\ct_web_dev\sites\all\modules\eva\eva.module).
    EntityMalformedException: Missing bundle property on entity of type field_collection_item. in entity_extract_ids() (line 7389 of C:\wamp\www\ct_web_dev\includes\common.inc).
rv0’s picture

Same problem here.

not using features.

mirian’s picture

I've the same problem....
Have you find any solution????
Or maybe another module that supply the same functionality?

thank you!
Miriam

Amir Simantov’s picture

Same here.

Notes

  1. Happens AFTER the node is actually saved or editted successfully.
  2. When trying to view the node, errors are displayed again.
  3. Hide the EVA views from the display of the node does not help.
  4. Errors are displayed also in content types not used as bundles in an EVA view.
  5. If value is removed when editing, no errors are displayed and node is displayed OK.

Table field_config_instance with thre relevant field instances looks fine:

337, 235, field_shared_partial_date, node, building, ..., 0 // The field_collection field
339, 235, field_shared_partial_date, node, organization, ..., 0 // The field_collection field used agin in another bundle (content type)
349, 243, field_shared_partial_date_day, field_collection_item, field_shared_partial_date, ..., 0 // First integer field
350, 244, field_shared_partial_date_month, field_collection_item, field_shared_partial_date, ..., 0 // Second integer field
351, 245, field_shared_partial_date_year, field_collection_item, field_shared_partial_date, ..., 0 // Thirdr integer field

Error

The website encountered an unexpected error. Please try again later.
Error message
Notice: Undefined variable: entity in _eva_extract_entity_from_build() (line 148 of [...]/sites/all/modules/eva/eva.module).
EntityMalformedException: Missing bundle property on entity of type field_collection_item. in entity_extract_ids() (line 7405 of [...]/includes/common.inc).

jgottwig’s picture

Incidentally (in case others are still dealing with this), I'm using both Eva and Field Collection, and moving to the Eva dev-branch fixed this issue for me.

dorianfm’s picture

As per #12, using EVA and Field Collection, updated to eva-7.x-1.x-dev.tar stopped this error message, which was appearing when I tried to run drush search-index.

Though just because the error message isn't showing up doesn't mean the issue is fixed, it's may just be better hidden :-/

bradjones1’s picture

Status: Active » Needs work
FileSize
591 bytes

Well after nearly 3 hours of hair-pulling, I have at least a work-around for this issue. I don't think the attached patch is a best-practice solution, but perhaps someone who is more familiar with Entity API and this module can get it where it needs to go.

Essentially, inside field_collection_field_widget_form(), we call field_collection_field_get_entity($items[$delta], $field_name) to get the entity, but on node creation that was failing (I think) on an unlimited-delta field when $delta was set to 1 -- Drupal's default behavior on such fields is to give you at least 2 blank fields to start with. So the first parameter we passed the function was junk, and it passed that on to entity_extract_ids(). If we unset the first parameter to field_collection_field_get_entity(), it has logic to use the field name instead.

That's why attached patch seems to work on new node creation (no existing data to give us a meaningful $delta) -- and if we are acting on an existing node with an nid, the module works as originally written.

I could be off on my diagnosis of the problem - but I think this is at least close.

tim.plunkett’s picture

Status: Needs work » Postponed (maintainer needs more info)

Is this still reproducible with dev versions of field_collection and eva?

Anonymous’s picture

Do you have Memcached installed ?

bradjones1’s picture

@tim.plunkett: This was with the -dev of field_collection and we're not using eva. This error just kinda appeared from nowhere, but I can rule out an interplay with eva.module since it's nowhere to be found in my environment. It does utilize the "embedded" widget on the node add/edit form, which is maybe where some of the confusion is coming from?

bradjones1’s picture

@Valor - I do on my dev environment, but not on production - and this problem appeared on both. For what it's worth.

Anonymous’s picture

Try to add this to settings.php and see if it works.

$conf['cache_class_cache_form'] = 'DrupalDatabaseCache';
rlmumford’s picture

We don't have eva, and are on the latest dev, (Feb 6th is the latest commit) and get the EntityMalformedException on new nodes and a new Application (application being a custom entity).

rlmumford’s picture

A fix similar too #14 appeared not to work

mrfelton’s picture

Using latest eva and field collection -dev code I got this error. Patch in #14 resolved for me.

goldenboy’s picture

Disabling EVA module works for me.

pwaterz’s picture

#14 patch is only for node entities and is not right. The problem is when field_attach_form is called on line 1002 and $field_collection_item is stubbed out right. I'm still trying to debug the problem. Will update when I find something.

pwaterz’s picture

#7 is correct, I believe this is being caused by features exporting entity info as json. I the problem is that when entity_extract_ids is being called, it is being passed json for the entity. I dont think this is a bug in the field collection module.

Here is the features bug http://drupal.org/node/1269750

pwaterz’s picture

Please try my patch here http://drupal.org/node/1269750. You will need to recreate your features, because this patch changes the way field collections will get exported.

Zdorovega’s picture

This error appear when I try to save entity:
$entity = entity_load('field_collection_item', $ids);
...
$entity_type = 'field_collection_item';
entity_save($entity_type, $entity);

dealancer’s picture

Thanks! Patch #14 helped me to remove those messages.

ExceptionHandler’s picture

Created field collection in one of my content types, then trying to create new content piece, results in error:

Notice: Undefined variable: entity in _eva_extract_entity_from_build() (line 148 of /var/www/html/drupal/sites/1/modules/eva/eva.module).
EntityMalformedException: Missing bundle property on entity of type field_collection_item. in entity_extract_ids() (line 7501 of /var/www/html/drupal/includes/common.inc).
ygerasimov’s picture

I completely agree with @pwaterz. In my case problem was with exported by feature field_collection that does not gets loaded properly.

Patch #14 is not good as field_collection can be attached to any entity and not only node.

xtfer’s picture

Im getting this bug without features present in the site, however it was caused by an issue with EVA. Updating THAT to its latest dev fixed this issue (which is the value of $entity being set to NULL at some point prior to reaching field_collection).

mrfelton’s picture

Status: Postponed (maintainer needs more info) » Needs review
FileSize
938 bytes

As stated already, the patch in #14 assume the collection is added to a node entity. I believe this is the cause of the issue in #1219646: Critical Error when field collection added to a User entity. Attached is a more generic patch, which also looks to resolve the other issue that I referenced. As well as my original issue at #1539222: Field collection entity not created properly when attached to user profile which was caused by the patch in #14.

liquidcms’s picture

i get this error on a few of my content types when i try to add a new node. i have never used eva. these were "imported" with features though but now that feature has been disabled.

this is with the patch in #32 applied

liquidcms’s picture

deleting the field collection field and re-adding it fixed my issue.

svenaas’s picture

Unfortunately the patch at #32 did not work for me. I still get
EntityMalformedException: Missing bundle property on entity of type field_collection_item. in entity_extract_ids() (line 7501 of /path/to/drupal/root/includes/common.inc).

pwaterz’s picture

@svenaas you need to recreate the feature to make it go away.

agentrickard’s picture

@pwaterz - Given that #1269750: Exporting a Field Collection field with a default value to Features leads to a PHP parse error is still in flux -- and that cross-module patches are a maintenance nightmare -- we should probably attack the drastic fail here in this issue.

There is NO excuse for a fatal error in this case.

mrfelton’s picture

Still having trouble here, and whilst the patch in #32 was an improvement, it's still giving problems for some entity types. Attached is a slightly different approach, which appears to be working for everything I have tried so far - field_collection_items on content types, users, commerce customer profile types, and custom entities created with the eck module.

David_Rothstein’s picture

Note that the issue linked to above (#1269750: Exporting a Field Collection field with a default value to Features leads to a PHP parse error) is most likely not a Features bug after all (or at least not directly) and for now I've put it back in this module's queue.

It sounds from the comments above like many people in this issue are experiencing a slightly different problem anyway (some not even using Features in the first place)... but to the extent that the two issues are related in some way it might be worth trying the latest patch in that issue and seeing if it helps also.

marvil07’s picture

The patch from comment 38 without the extra spaces.

alayham’s picture

#40 works for me on new node creation.

Anonymous’s picture

#40 works here, too!

tim.plunkett’s picture

Assigned: Unassigned » tim.plunkett

Assigning for review tomorrow/this weekend.

pwaterz’s picture

I dont think there is a bug here, I think this is related to this http://drupal.org/node/1269750

Kontrol_x’s picture

There's a patch for EVA Module that makes field collection error. http://drupal.org/node/1278742 This solved my problem.

yul63’s picture

Status: Closed (duplicate) » Needs review

Patch at #40 + deleting and recreating a Media video field in a Field collection did work for me. The original field was created by reusing an already existing one, which came from a Feature.

EDIT : Sorry about that, I still get the same message. And I don't have EVA installed.

pwaterz’s picture

Status: Needs review » Closed (duplicate)

I am 99% sure that this issue is the same as http://drupal.org/node/1278742. Please try patch there first.

30equals’s picture

Status: Needs review » Closed (duplicate)

I got the same error, but on line #7539 of common.inc, and this when i try to add a node of type which has a field collection - i applied the patch of #40, but it doesn't seem to make any difference.

30equals’s picture

Status: Closed (duplicate) » Needs review
FileSize
574 bytes

i have to mention that i only have this problem with a nested field collection so far. Aparently then in field_collection_field_widget_form (doing a backtrace: I think because of field_default_form get's called, returning an array) the $field_collection_item is an array instead of an object, which obviously results in an error because there's no property.

I crudely could avoid the error by checking if an array get's returned in field_collection_field_get_entity. i attached a patch, which solved my problem for now. Dunno for certain though that it's full proof for everyone or that it's the right direction for a fix.

tim.plunkett’s picture

Assigned: tim.plunkett » Unassigned
Priority: Major » Normal

If you're going to reopen this, fixing metadata.

Josh Benner’s picture

Using EVA 7.x-1.2 solved this for me.

phreaknerd’s picture

Had the same issue when trying to translate field_collections.

I've added a patch that populates new instances of field_collection_items with the correct bundle. Which makes the error go away and even seems to fix #1366220: Field collection translatable Field language for setHostEntity and #1683784: Field Collection entities are untranslatable because they do not define valid base path.

cossimo’s picture

#52 works for me when translating field collections. Any hope of it being committed?

faribafana’s picture

I tried all patches including #52. Nothing is working for me, even if I create a content type with a field collection from scratch.

phreaknerd’s picture

@faribafana: I tried it with a fresh drupal install (and in one of our project of course) and it works fine for me.

Can you provide a bit mor information please? What exactly is not working? Which Drupal version? Any helpful error messages?

Sometimes it helps to (temporarily) disable some modules to check if another module is interfering with this module.

faribafana’s picture

Sorry, I have described the problem in http://drupal.org/node/1724202 #2 . Here it is again:

I used features to bring in a content type that includes a couple of field collections. Then tried to create that content type. It creates ok, but does not display after created. The edit functionality is working, but view gives the following error:

EntityMalformedException: Missing bundle property on entity of type field_collection_item. in entity_extract_ids() (line 7562 of /var/www/drupal-7.15/includes/common.inc).

When I delete the field collections everything is fine. But when I recreate them, I get the error again. I am using Drupal 7.15 . I tried both field collection 7.x-1.0-beta4+10-dev and 7.x-1.0-beta4 with no luck. Any help is appreciated.

phreaknerd’s picture

Did you try to setup the content-type/field_collection manually without using features?
I think I've read somewhere about issues between features and field_collection...

faribafana’s picture

Yes, I tried that without any success. I also tried to create a simple content type and attach field_collection to it. That doesn't work either. The strange thing is that it works in my development environment, but not staging or production. The only difference between them is that we have APC installed on staging and production, but not in my development. So I disabled APC on staging, but even that did not help the problem go away.

phreaknerd’s picture

Well, in this case you have really to check the differences between your dev and prod environment. No other idea...

zterry95’s picture

I encounter the same problem with phreaknerd.
I have spent a whole day to study and try to solve it. but no result....

faribafana’s picture

The problem went away automagically when I left it alone for a 3 day weekend! The only thing that happened during these days is that the cache got flushed and rebuilt by cron a few times. Try flushing the cache a few times to see it it helps (I know one time flushing did not work for me). Good luck.

zterry95’s picture

Ahah...

the problem appear in wamp(winodws) envirement.
When I transfer the databases to linux, the problem fixed!!

So funny~~

SandraVdv’s picture

FileSize
31.11 KB

I also get this error when I try to load a form with a field_collection through drupal_get_form().
This is my code:

module_load_include('inc', 'node', 'node.pages');
$node_type = 'event_registration';
$form_id = $node_type . '_node_form';
global $user;
// Initialize new node:
$node = new stdClass();
$node->uid = $user->uid;
$node->name = (isset($user->name) ? $user->name : '');
$node->type = $node_type;
$node->language = '';
node_object_prepare($node);
 
// get the event_registration node form
form_load_include($form_state, 'inc', 'node', 'node.pages');
$form = drupal_get_form($form_id, $node);

return $form;

How do you attach the bundle information to a node you created programmatically?

_redfog’s picture

I have the same issue when I try to save a node which content field collection. But this error appears randomly. I can't reproduce it as I want. So it's difficult to correct it.

sinini’s picture

Using EVA 7.x-1.2 also helped me out

greggles’s picture

Priority: Normal » Major

Given the number of replies on this issue bumping the priority a smidge. Also, subscribing.

@tim.plunkett @fago - it would be great to get a review to know if this patch is on the right track or not.

thatjustin’s picture

So.... no one is going to believe me here. If I saw the comment I am about to make, I'd think "Oh, that's some novice who doesn't know what he's talking about." I'm not. Yet, I don't have a good explanation as to why this fixed it for me.

Edit /my.cnf so that you increase max_allowed_packet to 16M:
max_allowed_packet=16M (and restart mysqld)

Perhaps it was cosmic rays, or mysld just needed a restart, or perhaps there is an explanation in the code that one of you will understand that I don't. Suffice it to say that I was getting this error: EntityMalformedException: Missing bundle property on entity of type field_collection_item. entity_extract_ids() and I tried #52 and #38 (aka #40) which didn't help.

My problem may not have been the same as yours, for me it was coming up when I was using a Views Bulk Operation with the "Modify entity values (views_bulk_operations_modify_action)" option set and bulk editing entities that had field collections. I wasn't touching the field collections with my operation, but I'd still get the error.

I came to the solution by taking my prod env (where the problem was occurring) to my dev env, and encountered a different MySQL problem, which, upon googling around, was solved by increasing the max_allowed_packet. Once I did that, I couldn't reproduce the problem in dev. So, as Data says, "Once you have eliminated the impossible, whatever remains, however improbable, must be the truth." And the first significant difference between dev & prod at that point was their my.cnf files (and different minor version of PHP). So, I edited my my.cnf, restarted MySQL and poof! fixed.

If this ranty comment helps one person not waste the five hours that it took me to solve this, then it's worth it. This is the post that got me to edit this value.

_redfog’s picture

About #67...

I notice that:
1 - my problem "Missing bundle property on entity of type field_collection_item" randomly appears. Probably, this isn't a code mistake (as I had this error only on prod side).

2 - I have had sometimes this error too: "MySQL server has gone away query", which has been quoted previously (http://drupal.org/node/186384). I didn't think that it could be both related...

I'll check the property "max_allowed_packet"

EDIT: on prod, max_allowed_packet is already at 16M. Maybe this isn't enough.

ghalenir’s picture

liquidcms’s picture

i have recently updated a lot of modules on my site; including entity, entity ref, entity trans, and numerous others. i now get this error when saving one of my nodes.

the patch in #52 does not help.

debugging code i can see it is related to field collections

will keep looking.

liquidcms’s picture

the line that throws this error is:

if (!isset($entity->{$info['entity keys']['bundle']}) || $entity->{$info['entity keys']['bundle']} === '') {

in common.inc (and even though i also just updated core; this has not changed)

$entity->{$info['entity keys']['bundle']} returns NULL which is why error is thrown. which is basically that there is no $entity->type defined for a collection

still not sure when this occurred or from which module; tried back revving entity module but that throws other exceptions - my guess would still be on Entity

D7 - most complex and hardest to debug version of Drupal ever!! :(

liquidcms’s picture

my issue was due to updating Entity Translation module (and error occurred when saving node)

czigor’s picture

I have the same message when creating a new node with a FC and click the 'Add another item' button. If I save the node first and then click the 'Add another item' button, it works fine.

The patches #40 and #52 above did not work for me.

GaëlG’s picture

@liquidcms I also face this problem and I indeed updated Entity Translation to last dev. Did you fix the problem or reverted to a previous version of ET?

liquidcms’s picture

@GaëlG - i am using ET -alpha2

_redfog’s picture

@liquidcms : Having updated Entity Translation module, does it solved your problem ?

liquidcms’s picture

didn't update; i actually reverted from latest -dev to the older -alpha 2 version; and yes, that fixed my problem.

plach’s picture

@liquidcms:

I think you are talking about #1818620: Incompatibility with Field Collection introduced in ET -dev, I thought it was fixed. Can you help with it?

liquidcms’s picture

@plach.. entity, et and f collections scare the hell out of me.. lol.. although i have submitted a couple patches for fc. might have some time next week to look; launching a new site this weekend so will be tied up until then.

GaëlG’s picture

@plach It looks like the bug is gone in beta1.

plach’s picture

Good to know. Thanks @renat for reporting.

raspberryman’s picture

I'm trying to reproduce this issue with little luck. Below are my test cases.

Does anyone have steps to reproduce?

FEATURE #1: Field collectons

ENV: Drupal 7.17+2-dev, Field Collection 7.x-1.0-beta4+14-dev, Entity API 7.x-1.0-rc3+11-dev

SCENARIO #1: Field collections with 1 allowed value

Field Collection settings: Embedded, optional, 1 allowed value
Child fields:
* Text (Text field, optional, 1 allowed value)
* Integer (Text field, optional, default 1234, 1 allowed value)
* Image (Image, optional, default image is a .png, 1 allowed value)

  1. STEP: Add new content using default values - pass
  2. STEP: Add new content using new values - pass
  3. STEP: Edit content to new values - pass
  4. STEP: Delete content (verify in DB) - pass

SCENARIO #2: Field collections with 2 allowed values

Field Collection settings: Embedded, optional, 2 allowed values
Child fields:
* Text (Text field, optional, 1 allowed value)
* Integer (Text field, optional, default 1234, 1 allowed value)
* Image (Image, optional, default image is a .png, 1 allowed value)

  1. STEP: Add new content using default values - pass
  2. STEP: Add new content using new values - pass
  3. STEP: Edit content to new values - pass
  4. STEP: Delete content (verify in DB) - pass

SCENARIO #3: Field collections with unlimited allowed values

Field Collection settings: Embedded, optional, unlimited values
Child fields:
* Text (Text field, optional, 1 allowed value)
* Integer (Text field, optional, default 1234, 1 allowed value)
* Image (Image, optional, default image is a .png, 1 allowed value)

  1. STEP: Add new content using default values in 10 collections - pass
  2. STEP: Add new content using new values in 10 collections - pass
  3. STEP: Edit content to new values in 10 collections - pass
  4. STEP: Delete content (verify in DB) - pass

FEATURE #2: Field collectons + i18n

ENV: As in first feature, plus Multilingual content 7.x-1.7+8-dev

SCENARIO #1: Field collections with unlimited values in translated content

Field Collection settings: Embedded, optional, unlimited values
Child fields:
* Text (Text field, optional, 1 allowed value)
* Integer (Text field, optional, default 1234, 1 allowed value)
* Image (Image, optional, default image is a .png, 1 allowed value)

  1. STEP: Follow steps in Scenatio #3 above, in English, French, and Spanish - pass

FEATURE #3: Field collectons + Features

ENV: As in first feature, plus Features 7.x-2.0-beta1+1-dev

SCENARIO #1: Field collections with unlimited values exported then reverted via Features

Field Collection settings: Embedded, optional, unlimited values
Child fields:
* Text (Text field, optional, 1 allowed value)
* Integer (Text field, optional, default 1234, 1 allowed value)
* Image (Image, optional, default image is a .png, 1 allowed value)

  1. STEP: Export content type from the first Feature, Scenario #3 - pass
  2. STEP: Delete this content type - pass
  3. STEP: Revert feature - pass
  4. STEP: Repeat steps in first Feature, Scenario #3 - pass
Senpai’s picture

Status: Needs review » Fixed
Issue tags: +drupal.org D7, +porting

Based upon the O.P.'s comment #3, and comments #80 and #82 (especially #82) which cannot verify the current existence of this bug, I'm calling this one fixed.

Status: Fixed » Closed (fixed)

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

univate’s picture

This issues doesn't want to go away for me, attaching re-rolled patch based on #32 that fixes (or hides) the problem in case others need it.

I will leave the issue closed, as I don't have anything useful to add.

DamienMcKenna’s picture

jamsilver’s picture

If there are people still running into this error on entity forms created with ECK, then the bug is with ECK.

See #1922354: Doesn't work with ECK entities

andremolnar’s picture

I was running into this error - and was reliably able to reproduce it when using unlimited values of a field collection only when the node containing the field collection was embedded in a multi-step form.

I am not able to reproduce this bug in any other way. e.g. creating the same node directly (outisde of the multistep form) or re-using the field collection in a different node (also created in a normal node form).

So chances are people are doing something 'funky' to create the conditions that throw this error.

MrHaroldA’s picture

I just ran into this issue again while adding a custom view mode to "field_collection_item"

function MY_MODULE_entity_info_alter(&$entity_info) {
  $entity_info['field_collection_item']['view modes']['grid'] = array(
    'label' => t('Grid'),
    'custom settings' => FALSE,
  );
}

After enabling it in the display settings and changed my view to use the newly created 'Grid' mode, I now only get fatal errors ;)

klokie’s picture

@Valor - did you figure out why using memcache would trigger this exception?
I've seen the same sorts of issues, that all go away after I disable memcache.

lonehorseend’s picture

I am having this problem with media, field collections and conditional fields installed. I had to patch conditional fields to work with field collections so that the choice between video and a picture could be made. That part works fine. If I choose pictures it works fine, but if I choose media, the node bails with the missing bundle error.

What is interesting is that it's happening when I try to invoke the MediaFront player. Hmmm . . . So maybe it's not field collections per say.

EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7663 of /includes/common.inc).

I have filed a similar complaint under the MediaFront player plugin.

Zdrav4e’s picture

#52 works for me when translating field_collections. One more upvote and I really really hope it gets commited. I'm using Field Collection 7.x-1.0-beta5, Entity API 7.x-1.2+11-dev, Entity translation 7.x-1.0-beta3, Drupal 7.24.

The field collections has unlimited number of values, only the field collection itself is translatable, not the fields inside of it.

ricovandevin’s picture

Combination of Field Collection and Entity Translation was throwing an EntityMalformedException for us too when saving a translation of a node. The patch in #52 seems to have solved this issue although I had to re-roll it against Field Collection 7.x-1.0-beta5+8-dev. See the re-rolled patch attached.

SocialNicheGuru’s picture

I cannot apply the path:

--- HEAD
+++ Modified In Working Tree

Which files should it apply to?

ricovandevin’s picture

Sorry I was in hurry yesterday and did not check the contents of the patch file generated by NetBeans IDE. Does the one attached now work?

maxplus’s picture

Hi,

thanks for the patch!

#95 works for me to translate a node containing a field collection an before throwing a "Missing bundle property on entity" error on saving the translated node with Entity Translation.

rlmumford’s picture

Status: Closed (fixed) » Needs work
+++ b/field_collection.module
@@ -1669,7 +1669,19 @@
+  elseif ($form_state['input'][$field_state['array_parents'][0]][$field_state['array_parents'][1]][$element['#delta']]) {

This should be parents not array_parents surely?

SocialNicheGuru’s picture

This patch seems to work.
But it does not work if there is a field_collection within a field_collection. Please see issue: https://drupal.org/node/2232593

SocialNicheGuru’s picture

jay.lee.bio’s picture

#67 solved my problem. How I eventually figured it out was when I looked further into the following error message that was always attached to the more severe "EntityMalformedException" error message every time I tried to add a field collection to a node:

Notice: Undefined offset: 17 in field_collection_field_widget_embed_validate()

In my case, I realized that I couldn't attach more than 17 field collections no matter what I did. After sifting through this issue, I eventually had my "Aha!" moment when I read #67 and realized that this was most likely due to some size restriction. And bingo, problem solved. Thatjustin, you the man. Thanks so much!

hgouveia’s picture

#99 patch solved the error, but not showing the content in other languague, it saves all item as "EN" language , use #52 patch instead, but this not copy the EN content, needs to reenter

TanvirAhmad’s picture

None of the patches worked for me.

bpadaria’s picture

I am getting this error by changing my required field to optional.

And then if left it blank.

sinasalek’s picture

Patch #95 solved the problem for me

sinasalek’s picture

Upgraded to the latest dev snapshot, encountered the issue again, patched it using #95, and the issue still exists
Using Drupal 7.32

EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids()
(line 7740 of /public_html/includes/common.inc).
8bitplateau’s picture

In my situation the function field_collection_field_widget_form() seems to be the cullprit.
Around #1476 the code $field_collection_item->setHostEntity($element['#entity_type'], $element['#entity']); is called in the fields manage form for the field collection. It seems to be creating an empty collection to use to set the default values but it can not set a parent (node in this case) as there isn't one.

I simply changed this line to :

  if (isset($element['#entity'])) {
    $field_collection_item->setHostEntity($element['#entity_type'], $element['#entity']);
  }

And it seems to have no ill affects. The default settings are still saved and all field collection work on forms and node views.
Anyone see anything wrong with this ? as it's working for me but it might be doing something nasty somewhere.

pdesai’s picture

#106 did the trick for me! Thanks @digitisation

UPDATE: The beta8 didn't include this so I had to add it back - it's on line 1470 now.

jienckebd’s picture

#95 worked for me -- any chance we can get one of these committed so we don't have to patch the module?

nimek’s picture

#106 solved the problem. Please commit

gabesullice’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
1.14 KB

#95 worked for me. Marking as RTBC.

Renamed the patch with the proper naming conventions so that it, hopefully, gets queued for testing.

jmuzz’s picture

Status: Reviewed & tested by the community » Postponed (maintainer needs more info)

The comments are saying this happens when saving nodes using entity translation. The current beta and dev versions of field collections do not yet support entity translation. If you need field collections to work with entity translation you can try the patch in the issue for it: #1344672: Field Collection: Field translation (entity_translation) support.

Maybe this can be closed as a duplicate. The change in #110 is a part of the entity translation patch already.

Can anybody provide steps to reproduce this without using entity translation?

jmuzz’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)
AaronBauman’s picture

Status: Closed (cannot reproduce) » Reviewed & tested by the community

I'm having the same error on a site without translation.

The last submitted patch, 93: missing_bundle_property-1281974-52_rerolled.patch, failed testing.

jmuzz’s picture

Status: Reviewed & tested by the community » Postponed (maintainer needs more info)

Thank you for the update @aaronbauman. Does applying #95 fix the problem for you?

Can anybody provide steps to reproduce the error without using translation or the translation patch for field collection?

The part of the entity translation patch containing these changes has been pointed to as potentially causing problems, so it might be better to wait until that can be resolved before applying the changes (likely as part of the entity translation issue).

https://www.drupal.org/node/1344672?page=1#comment-10464253

Jochen Wendebaum’s picture

This error showed up for me after upgrading from beta8 to beta9.
Downgrading to beta8 removed this error again.

I am using the translation facilities, too.

jastraat’s picture

Similar to @Jochen Wendebaum, this error appeared after upgrading from beta8 to beta9. Downgrading to beta8 removed the error.

The error did not appear when testing locally but appeared after we pushed the changes to staging. (Which is running memcache and varnish). All our configuration is features-based so configuration (content types / views / variables / installed modules) should be the same between local and staging.

Wondering if this might be content related with orphaned entities similar to https://www.drupal.org/node/1778572

We are not using anything related to translation.

egontinno’s picture

I have same situation as @jastraat described. Locally no problems, but fatal error after we pushed it to production.
Downgrading to beta8 removed the error.

Nitebreed’s picture

I also had this problem locally on beta10 (we also use memcache locally). Also in our case we don't do anything with translations. Downgrading to beta8 fixes the issue.

leovw’s picture

I am experiencing the same error on beta 10 too. We are on Acquia hosting which uses Varnish. Works fine locally. We don't have any translation on this site. Downgrading for now.

akalata’s picture

For issues related to updating past -beta8, see #2609396: Missing bundle property on entity, not related to translation.

AaronBauman’s picture

I've still got this error when updating from beta8 to beta10.
Neither #95 or the reroll in #110 fix the issue.

entity_extract_ids() is getting an array, not an object.

AaronBauman’s picture

Status: Postponed (maintainer needs more info) » Needs work
akalata’s picture

Status: Needs work » Postponed
akalata’s picture

Title: Missing bundle property on entity » Missing bundle property on entity - related to translations
Status: Postponed » Postponed (maintainer needs more info)
stijndmd’s picture

in beta 10 we still have this issue.
patch in #110 fixed it for us.

would be great if this gets committed at some point

jastraat’s picture

Status: Postponed (maintainer needs more info) » Needs review

Setting to "needs review" for test bot.

Plazik’s picture

Fixed code style in patch from #110.

jmuzz’s picture

Status: Needs review » Fixed

The changes proposed in this patch have been committed. I believe it was for #1344672: Field Collection: Field translation (entity_translation) support.

Status: Fixed » Closed (fixed)

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

Elijah Lynn’s picture

liquidcms’s picture

Sadly d.org no longer allows re-opening issues.. but will post here and then make new issue (duplicate).

Just upgraded FC from beta4 to latest (beta13) to attempt to handle issue with uprading PHP to 7.2. Site now WSOD with:

EntityMalformedException: Missing bundle property on entity of type field_collection_item. in entity_extract_ids() (line 7947 of E:\www\Squared\cppenv\docroot\includes\common.inc).

I've gone back to beta8 as mentioned above and then replaced the fetchHostDetails() function to make it suitable for PHP 7.2