By chandika on
Hey all,
In a custom module of mine, I have 2 methods which loads a CCK node and alters some of the content. The issue is that only the changes from the last executed node_save is recorded in the database. The 1st save operation is always ignored! Am I doing something wrong here?
Example code:
function abc_cron(){
_abc_function1();
_abc_function2();
}
function _abc_function1() {
/*Logic for selecting $node_id etc...*/
$tmpNode = node_load($node_id);
$tmpNode->field_vote_count = array (0 => array ('value' => $newVotes));
$tmpNode->field_chart_score = array (0 => array ('value' => $newScore));
node_save($tmpNode);
}
}
function _abc_function2() {
/*Logic for selecting $node_id etc...*/
$tmpNode = node_load($node_id); //73
$tmpNode->field_vote_count = array (0 => array ('value' => $newVotes));
$tmpNode->field_chart_score = array (0 => array ('value' => $newScore));
node_save($tmpNode);
}
}
So in the above scenario, only changes made by _abc_function2() is persisted. However, if I comment out _abc_function2(), the 1st method saves its changes.
Thanks!
PS: I have omitted some of the code from the functions above which does not have any impact on node operations. But if this is required for clarity, please let me know and I'll post it.