I recently created a new profile type - so I now have two. The new profile contains a subset of my first profile type. Everything seemed to work and I created a new test user with the new profile. However, now when I try to view the profile details for any user, I get the following error:

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

Existing data seems to be OK - and I can get to the edit screens by typing in the address.
I also have the i18n module installed (among many others).

Any idea what could be wrong?

Comments

jide’s picture

Having the same issue.

DropInTheOcean’s picture

Hi Jide, There was a preceding error in the log referring to the Eva module. So I found the same problem—and a patch that worked—on the Eva forum: http://drupal.org/node/1278742 ... hope this helps you too.

fago’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

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

joeclarkia’s picture

Status: Closed (fixed) » Needs review

I'm seeing this issue too. I don't think it's exactly the same as the Eva issue (undefined entity vs. missing bundle property). For me the issue shows up when I enable Aggregation in views. That's when I see this error: "EntityMalformedException: Missing bundle property on entity of type profile2. in entity_extract_ids() (line 7405 of /var/www/includes/common.inc).". At this point I can't edit the view at all due to this error, so I can't even turn aggregation off.

pandabrand’s picture

I'm not using the eva module at all and I'm getting this? what do i do? it's completely broken the admin portion of my site. I have a custom theme for my site but i'm using seven as my admin theme and now it won't come up.

pandabrand’s picture

ok, i found my problem when i had this in my header:

global $user; 
$profile_two = profile2_load_by_user($user, 'main');
$fields = field_get_items('profile2',$profile_two,'field_first_name');
print $fields[0]['value'];

this threw that error when I went to my logged in page under the drupal admin. anything?

fago’s picture

Status: Needs review » Active

No patch to review.

pandabrand’s picture

skip this, value wasn't set in this account. dumb moves.

rooby’s picture

I'm getting the same error message as the original poster in views where I have a search_api view returning user results, which have associated profile2 profiles.

rooby’s picture

Category: support » bug

This is actually a bug report because it is throwing errors, but I don't yet know what module it belongs to.
It is possible that it belongs to a number of different modules that have problems with their integration with profile2.

rooby’s picture

Actually, with my issue the error only occurs during the views live preview.

rooby’s picture

kclarkson’s picture

I am having this issue with EVA as well.

I understand there is a patch for EVA but if this is happening with other modules then could it be something in the code of Profile2?

jdlind38’s picture

I noticed my issue stemmed from the Field Permissions module. I noticed that the Field Permissions module pushed out a new beta (7.x-1.0-beta2). The autocomplete started to work and the error went away. Make sure that the "Don't sort" option is selected in the reference field.

lpc’s picture

Hi,

#7

Had same problem with profile2. Try passing $profile_two['profile_name'] instead of $profile_two to field_get_items. It worked for me.

shythai’s picture

deggertsen’s picture

I'm having this problem as well for users who have not yet completed their profiles (it works fine for those who have completed their profiles). I have a feeling it has something to do with the following code as mentioned in #16, but I haven't been able to figure out how to fix it.

<?php
$uid = $elements['#account']->uid;
$family = profile2_load_by_user($uid, 'family');
$contact_information = profile2_load_by_user($uid, 'contact_information');

print drupal_render(field_view_field('profile2', $family, 'field_family_picture', 'value'));
print drupal_render(field_view_field('profile2', $contact_information, 'field_ol_locator_address', 'value'));
?>
deggertsen’s picture

Version: 7.x-1.0 » 7.x-1.3

Changing the version.

deggertsen’s picture

I fixed it for my case by adding conditional statements as follows:

<?php
$uid = $elements['#account']->uid;
$family = profile2_load_by_user($uid, 'family');
$contact_information = profile2_load_by_user($uid, 'contact_information');

print (empty($family) ? '' : drupal_render(field_view_field('profile2', $family, 'field_family_picture', 'value')));
print (empty($contact_information) ? '' : drupal_render(field_view_field('profile2', $contact_information, 'field_ol_locator_address', 'value')));
?>

Not sure if it's the best solution, but it works.

firfin’s picture

Status: Active » Closed (duplicate)

This error comes from using field_view_field() or field_get_items() with an empty or incorrect entity.

Problems like this usually come from custom code. Either in your custom theme, module, computed field or php text field. Therefore I think this is a duplicate of #1328534: EntityMalformedException.

If this is not the case please reopen AND provide steps to reproduce this problem.

davewilly’s picture

Issue summary: View changes

#16 worked for me:

<?php
// load profile
$profile = profile2_load_by_user( user_load($form['#user']->uid, 'student') );

// get fields, specifying profile type
$fc_fields = field_get_items( 'profile2', $profile['student'], 'field_student_campaigns' );
        
dpm($fc_fields);
?>
arnoldbird’s picture

Not sure if it's been said, but be sure to check that you actually have a profile:

$profile = profile2_load_by_user($account, 'main');

if ($profile) {
  $my_field = field_get_items('profile2', $profile, 'field_my_field');
  // Do more stuff.
}

Simply creating a profile type does not mean that users have profiles. They have to save their account subsequent to your creating the profile type, or they don't yet have a profile.