Tell me more ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

I used to run successfully the following custom PHP code in rules before a node is stored

$update_node = node_load($node->nid);
$lat1 = floatval($node->field_geo["und"][0]["lat"]);
//SOME MATH HERE
$update_node->field_winkel_dorf["und"][0] = array("value"=>$winkel);
node_save($update_node);
}

But now after a major update of lots of modules I get this error: EntityMalformedException: Fehlende Paketeigenschaft auf einem Element des Types node. in entity_extract_ids() (Zeile 7663 von /var/www/vhosts/mydomain/httpdocs/includes/common.inc).

I have no idea what changed....

Any help very very welcome.

share|improve this question
1  
why are you using node_save before node stored? – Aboodred1 May 20 at 18:20
hhmmm... I have no idea. I actually don't really understand whats happening there but it used to work very well. But it seems the problem lies in th node_load command, sice I can't print_r($update_node); – Jo Pfeffer May 20 at 18:57

1 Answer

up vote 2 down vote accepted

You need to remove the first line $update_node = node_load($node->nid); because nid does not exist yet in node object then remove the last line as well node_save($update_node);.

Also, replace each $update_node variable with $node which is available by rules module.

Your final code should look like the following:

$lat1 = floatval($node->field_geo["und"][0]["lat"]);
//SOME MATH HERE
$node->field_winkel_dorf["und"][0] = array("value"=>$winkel);
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.