I don't understand what's wrong! Yesterday everything went fine, then I eliminated my php notices, now drupal doesn't update my nodes. Instead

Situation: I have 2 node types: kk_match which updates fine, and team_value where the problem exists. Although I took the same process.

The codes:

1: content-type kk_match what's ok:

$node = new stdClass();
       	$node->type = 'kk_match';
       	node_object_prepare($node);
       	$node->nid = $nid_kk_match;
       	//$node->vid = $nid_kk_match;
       	$node->language = LANGUAGE_NONE;
       	$node->field_punkte_heimteam ['und']['0']['value']= $punkte_h_temp;
       	$node->field_punkte_gastteam ['und']['0']['value']= $punkte_g_temp;
       	$node->field_timestamp_konvertierung['und']['0']['value']='946706400';

These nodes were imported and manipulated.

2: content-type team_value, ran perfectly yesterday (not used anymore):

$node = new stdClass();
       	$node->type = 'team_value';
       	node_object_prepare($node);
       	$node->title = $heimteamnames_tv;
       	$node->nid = $nid_heimteam_tv;
       	//$node->vid = $nid_heimteam_tv;
       	 $node->language = LANGUAGE_NONE;
       	$node->field_tore_heimteam_tv['und']['0']['value']=$heimteam_heimtore_tv_new;
       	$node->field_tore_heimteam_aktuell_tv['und']['0']['value']=$heimteam_heimtore_aktuell_tv;       	
       	$node->field_tore_gastteam_tv['und']['0']['value']=$heimteam_gasttore_tv_new;
       	$node->field_tore_gastteam_aktuell_tv['und']['0']['value']=$heimteam_gasttore_aktuell_tv;
       	$node->field_punkte_tv['und']['0']['value'] = $punkte_h_tv_new;
       	$node->field_punkte_aktuell_tv['und']['0']['value'] = $punkte_h_tv_new;
       	$path = 'content/results/'.$node->title;
       	$node->path = array('alias' => $path);
       	node_save($node);

... now it doesn't.

After googliing a lot the 3rd code to force to update:

if(!isset($nid_heimteam_tv)){
     	$node = new stdClass();
       	$node->type = 'team_value';
       	node_object_prepare($node);
       	}
       	else{
       		$node = node_load($nid_heimteam_tv);
       	}
       	$node->title = $heimteamnames_tv;
       	//$node->nid = $nid_heimteam_tv;
       	//$node->vid = $nid_heimteam_tv;
       	$node->language = LANGUAGE_NONE;
       	$node->field_tore_heimteam_tv['und']['0']['value']=$heimteam_heimtore_tv_new;
       	$node->field_tore_heimteam_aktuell_tv['und']['0']['value']=$heimteam_heimtore_aktuell_tv;       	
       	$node->field_tore_gastteam_tv['und']['0']['value']=$heimteam_gasttore_tv_new;
       	$node->field_tore_gastteam_aktuell_tv['und']['0']['value']=$heimteam_gasttore_aktuell_tv;
       	$node->field_punkte_tv['und']['0']['value'] = $punkte_h_tv_new;
       	$node->field_punkte_aktuell_tv['und']['0']['value'] = $punkte_h_tv_new;
       	$path = 'content/results/'.$node->title;
       	 
       	$node->path = array('alias' => $path);
       	node_save($node);

And here's the outcome by updating my site 3 times:
Overview:
http://farm3.staticflickr.com/2888/10208685456_981a7ea501_o.png
node 1:
http://farm4.staticflickr.com/3799/10208674025_9150c28beb_o.png
node 2:
http://farm8.staticflickr.com/7317/10208562966_4109aa23cf_o.png

As you can see, drupal saves the same node with the same content, same nid and vid 3 times!???
Also the timestamps are the same!???

Comments

Sawascwoolf’s picture

Hi, it can`t be that drupal saves 3 nodes with the same nid, please check your database (table: node) to verify this.

If there are really 3 entries with the same nid, I would suggest you to reinstall drupal and start again with developing.

Jaypan’s picture

Yeah, the NID is a unique key, and the db will not even let you save a duplicate. So if it is true that your system is accepting duplicate NIDs, it means someone changed the field to allow duplicates. This is a big no-no. And you would assume that this means they've done this for their own reason, which is probably something they pieced together in your system.

Either that, or you are misdiagnosing it. You will know when you look in the {node} table of the database.

maen’s picture

Sorry for answering so late, but I didn't receive emails the last days from drupal. I found a mistake in my coding. But I didn't look at the tables. So I didn't figure out if they were inserted multiple times.

But anyway thank you for answering!

maen