Something quite weird at node_save...(my own code will be for sure). I have a module which, amonbg others, means to manipulate its own nodes dinamically. Let's see next chunk
function _ugmgr_add_camnode($camera, $create = FALSE) {
$node = new StdClass();
if($create) {
$node->type = NODE_CAMTYPE;
$node->uid = 1;
$node->format = 1;
$node->status = 1;
} else {
$node->nid = $camera['node'];
}
$node->title=t('You are watching Camera '.$camera['cid']);
$node->body = "test BODY will BE :: ".$camera['description'];
node_save($node);
.....
}The very fisrt time I use this function, my new node body it is created as expected but, when I recall it with update intentions ($create = FALSE), the
body never changes at all, it all remains like the very first time.
Being a bit confused now about node_save and overall _node_revision_save, I just debug through mysql, where I found next query as result as my node_save :
UPDATE node_revisions SET nid = 25, uid = 1, title = 'Whatever' body = 'BODY will be=first desc', teaser = '', timestamp = 1276271512, format = 0 WHERE vid = 0And my node and its unique revision both have nid = vid = 25; Why does the code issue a VID=0 ?
What have I missed in my dinamic node manipulation which causes this behaviour ?
Comments
I think I'll answer myself
Silly me stupid stupid !
$node = new StdClass();$node->revision of course empty.
So I will try
$node = node_load($camera['node']);instead of
$node->nid = $camera['node'];I will kick my own a!@
$node->revision should be NOT
$node->revision should be NOT empty = I do not know its purpose value type so I set it to 1 in my code...
HTH, velko.org
http://crossloop.com/rsvelko