Update of /cvs/scoop/scoop/struct/patch-files/0.9-1.0
In directory lithium.sabren.com:/tmp/cvs-serv18382/struct/patch-files/0.9-1.0

Modified Files:
	script-14-post.pl 
Log Message:
Well this bug has been outstanding for quite long enough.

--rusty


Index: script-14-post.pl
===================================================================
RCS file: /cvs/scoop/scoop/struct/patch-files/0.9-1.0/script-14-post.pl,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** script-14-post.pl	2 Jul 2004 06:41:41 -0000	1.1
--- script-14-post.pl	28 Jan 2005 20:05:40 -0000	1.2
***************
*** 318,322 ****
  		return;
  	}
! 	mesg("done\n  Inserting into blocks...");
  	my $ins_sth = $dbh->prepare("INSERT INTO blocks (bid, block, description, category) VALUES (?, ?, ?, ?)");
  	my $remove;
--- 318,323 ----
  		return;
  	}
! 	mesg("done\n  Inserting/Updating Blocks (from Vars)...\n");
!         my $upd_sth = $dbh->prepare("UPDATE blocks SET block = ?, description = ?, category = ? WHERE bid = ?");
  	my $ins_sth = $dbh->prepare("INSERT INTO blocks (bid, block, description, category) VALUES (?, ?, ?, ?)");
  	my $remove;
***************
*** 324,333 ****
  		my $category = ($name eq 'slogan') ? 'site_html' :
  			(($name eq 'digest_subject') ? 'email' : 'display');
! 		$ins_sth->execute($name, $val, $desc, $category);
  		$remove .= ' OR ' if $remove;
  		$remove .= 'name = ' . $dbh->quote($name);
  	}
- 	mesg("done\n");
  	$ins_sth->finish;
  	$sth->finish;
  
--- 325,342 ----
  		my $category = ($name eq 'slogan') ? 'site_html' :
  			(($name eq 'digest_subject') ? 'email' : 'display');
! 		my $rv = $upd_sth->execute($val, $desc, $category, $name); # Order matters
! 		mesg("Updating Block '$name' from Variable...");
! 		mesg($dbh->errstr."\n") if $dbh->err;
! 		if($rv eq '0E0'){	# Aparently we need to add the item.
! 			mesg("Failed\n");
! 			$ins_sth->execute($name, $val, $desc, $category);
! 			mesg("Attempting Insert of '$name' instead.\n");
! 			mesg($dbh->errstr."\n") if $dbh->err;
! 		} else{mesg("Done\n");}
  		$remove .= ' OR ' if $remove;
  		$remove .= 'name = ' . $dbh->quote($name);
  	}
  	$ins_sth->finish;
+ 	$upd_sth->finish;
  	$sth->finish;