Updated: Comment #4

Problem/Motivation

When importing a set of nodes that contain organic group dependencies, I'm getting the following error:
EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7693 of includes/common.inc).

I have previously applied the patch in #1896384: Entity references and taxonomy terms break when importing nodes so that node dependencies would match up as expected, and I think it may have either caused or brought to light this error.

During node save, organic groups is trying resolve the group in og_group_refs, but that still references the old node id which may or may not be correct anymore. There is a dependency in the node object which does properly reference the OG node. If I simply unset og_group_refs before saving the node on import, and then let node_export_dependency do it's thing, it works as expected.

Proposed resolution

I'm attaching a patch based on the 7.x-3.x branch, but it conflicts with the patch in #1896384: Entity references and taxonomy terms break when importing nodes which is probably a prerequisite.

Remaining tasks

Fix conflicts with #1896384: Entity references and taxonomy terms break when importing nodes.
(Recreate the patch using the result of #1896384: Entity references and taxonomy terms break when importing nodes

Review & test.

Comments

jrb’s picture

I'm seeing the same issues that you are in importing OG nodes. I'm not following how the proposed solution in your patch works with the patch in #1896384: Entity references and taxonomy terms break when importing nodes, though.

Could you please post a patch that combines yours with the one in #1896384 so that I can see what the final result is supposed to be?

areke’s picture

Issue summary: View changes
jrb’s picture

Status: Active » Needs review
StatusFileSize
new3.69 KB

Originally, I tried creating a patch that combined the one above and the one in #1896384: Entity references and taxonomy terms break when importing nodes. When I tried to run an import, though, I got the original "Missing bundle property on entity of type node" error. Because of this, I assumed that I hadn't created the combined patch correctly. That led to my question above. But, the actual problem was that I had an OG Group Reference field on some content types that wasn't named "og_group_ref". So, the combined patch was working correctly, but only with the default field name.

I've created a patch that combines the one from #1896384 with the one above and works with any OG Group Reference field. I had to write a little code to figure out which fields were OG Group Reference fields so it would know which fields to unset(). If there's a better/easier way to do that, let me know.

Also, if it would be better to write a patch that works from the result of #1896384 (rather than combining), I can do that instead.

areke’s picture

Issue summary: View changes

Use summary template

jrb’s picture

Issue summary: View changes
StatusFileSize
new2.07 KB
jadhavdevendra’s picture

I managed to get rid of this error with replacing "target_id" from node export code to the one from destination system.
Lets say "A" is the node id of group from source Drupal. In node export code you will have

'og_group_ref' => array(
  'und' => array(
    array(
      'target_id' => 'A',
    ),
  ),
),

Find the node id of same group in destination Drupal. Say "B". Update your node export code to below.

'og_group_ref' => array(
  'und' => array(
    array(
      'target_id' => 'B',
    ),
  ),
),

This fixed the error for me.

suydam’s picture

I'm getting this same error trying to import a node that has User Reference and File fields.
I'm not understanding how i can fix this... the uid to which I'm trying to refer actually exists no problem in the target system, so it's not a failed linkage as far as I can see.

Did anyone ever patch this thing to solve that problem?

danielb’s picture

Status: Needs review » Closed (outdated)

Reopen if this is an issue with the latest code.