Rules in Drupal 7: EntityMalformedException in custom PHP I used to run successfully the following custom PHP code in rules before a node is stored

$update_node = node_load($node-&gt;nid);
$lat1 = floatval($node-&gt;field_geo["und"][0]["lat"]);
//SOME MATH HERE
$update_node-&gt;field_winkel_dorf["und"][0] = array("value"=&gt;$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.
You need to remove the first line $update_node = node_load($node-&gt;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-&gt;field_geo["und"][0]["lat"]);
//SOME MATH HERE
$node-&gt;field_winkel_dorf["und"][0] = array("value"=&gt;$winkel);