Hi,

I have been trying to use node_save() instead of poking around with the database tables as I want to do things the proper 'Drupal' way, however I have hit an annoying problem. I am using node_save() to insert a new CCK node that I have defined, which is does, unfortunately it continues to add entries to the 'node' table until the script is stopped or exhausted.

I have searched here and on the web in general and all I have found this issue which dates back to 2005 http://drupal.org/node/27007 I don't know enough about Drupal's internals to know if this is the problem I am hitting or not?

Below is the code the I am using "mynodetype" is the CCK node I have set up, I have not reached the stage of trying to write to the CCK fields yet I am just setting up the basic node. If $newnode->type is set to an undefined node type the it inserts only once. The CCK node has fields related to other nodes and it uses Automatic Nodetitles.

        $newnode = new stdClass();
	$newnode->nid = '';
	$newnode->vid   = '';
	$newnode->title = 'Test';
	$newnode->body = 'Test';
	$newnode->uid = $user->uid;
	$newnode->teaser = '';
	$newnode->type = 'mynodetype';
	$newnode->status = 1;
	$newnode->comment = 2;
	$newnode->promote = 0;
	$newnode->moderate = 0;
	$newnode->sticky = 0;
	node_object_prepare($newnode);
	node_validate($newnode, $error);
	node_save($newnode);

Am I missing a step?

Many thanks RdN

Comments

RdN’s picture

The node contained Computed CCK fields which called code in the same module when these were removed this stopped happening.