I "believe" I've found an issue when creating nodes programmatically and switching databases.

Basically, when doing the following, the embedded video fails to save to the database. The node is created, but any reference to the emfield is just NULL'ed.

db_set_active("production");
$query = db_query("SELECT nid,title,type FROM {node} WHERE nid = 3150");
while($node = db_fetch_object($query)) {
	$source = node_load($node->nid);
}

db_set_active("default");
		
$node = array(
	"title" => $source->title,
	"body" => $source->body,
	"type" => "story"
);

$node["field_video"][0]["embed"] = "http://www.youtube.com/watch?v=cFEarBzelBs";
		
if ($node = node_submit($node)) {
	node_save($node);
}		

When removing any db switching, it works fine.

Comments

ytokan’s picture

Hi
look here http://realize.be/nodeload-after-switching-database-cck-dangerous and the comment's
I have the same probleme. It's come with the node_load function and CCKfied cache

I trie this function to swith databe

function mymodule_switch_db($db) {
  db_set_active($db);
  cache_clear_all();
  drupal_get_schema(NULL, TRUE);
} 

Yto