From 61ddf0a32846fdf2607043d94af1a0a86b80f6fc Mon Sep 17 00:00:00 2001 From: "bbaetz%student.usyd.edu.au" <> Date: Mon, 12 Aug 2002 12:42:42 +0000 Subject: Bug 43600 - Convert products/components to use ids instead of names. Initial attempt by jake@bugzilla.org, updated by me r=joel, preed --- editmilestones.cgi | 54 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 24 deletions(-) (limited to 'editmilestones.cgi') diff --git a/editmilestones.cgi b/editmilestones.cgi index fccf72533..67d84fcce 100755 --- a/editmilestones.cgi +++ b/editmilestones.cgi @@ -33,9 +33,9 @@ sub TestProduct ($) my $prod = shift; # does the product exist? - SendSQL("SELECT product + SendSQL("SELECT name FROM products - WHERE product=" . SqlQuote($prod)); + WHERE name=" . SqlQuote($prod)); return FetchOneColumn(); } @@ -62,9 +62,9 @@ sub TestMilestone ($$) my ($prod,$mile) = @_; # does the product exist? - SendSQL("SELECT product,value - FROM milestones - WHERE product=" . SqlQuote($prod) . " and value=" . SqlQuote($mile)); + SendSQL("SELECT products.name, value + FROM milestones, products + WHERE milestones.product_id=products.id AND products.name=" . SqlQuote($prod) . " and value=" . SqlQuote($mile)); return FetchOneColumn(); } @@ -183,10 +183,10 @@ if ($milestone) { unless ($product) { PutHeader("Select product"); - SendSQL("SELECT products.product,products.description,'xyzzy' + SendSQL("SELECT products.name,products.description,'xyzzy' FROM products - GROUP BY products.product - ORDER BY products.product"); + GROUP BY products.name + ORDER BY products.name"); print "\n"; print " \n"; print " \n"; @@ -216,10 +216,11 @@ unless ($product) { unless ($action) { PutHeader("Select milestone for $product"); CheckProduct($product); + my $product_id = get_product_id($product); SendSQL("SELECT value,sortkey FROM milestones - WHERE product=" . SqlQuote($product) . " + WHERE product_id=$product_id ORDER BY sortkey,value"); print "
Edit milestones of ...Description
\n"; @@ -259,6 +260,7 @@ unless ($action) { if ($action eq 'add') { PutHeader("Add milestone for $product"); CheckProduct($product); + my $product_id = get_product_id($product); #print "This page lets you add a new milestone to a $::bugzilla_name tracked product.\n"; @@ -287,6 +289,7 @@ if ($action eq 'add') { if ($action eq 'new') { PutHeader("Adding new milestone for $product"); CheckProduct($product); + my $product_id = get_product_id($product); # Cleanups and valididy checks @@ -305,10 +308,9 @@ if ($action eq 'new') { # Add the new milestone SendSQL("INSERT INTO milestones ( " . - "value, product, sortkey" . + "value, product_id, sortkey" . " ) VALUES ( " . - SqlQuote($milestone) . "," . - SqlQuote($product) . ", $sortkey)"); + SqlQuote($milestone) . ", $product_id, $sortkey)"); # Make versioncache flush unlink "data/versioncache"; @@ -330,16 +332,17 @@ if ($action eq 'new') { if ($action eq 'del') { PutHeader("Delete milestone of $product"); CheckMilestone($product, $milestone); + my $product_id = get_product_id($product); - SendSQL("SELECT count(bug_id),product,target_milestone + SendSQL("SELECT count(bug_id), product_id, target_milestone FROM bugs - GROUP BY product,target_milestone - HAVING product=" . SqlQuote($product) . " + GROUP BY product_id, target_milestone + HAVING product_id=$product_id AND target_milestone=" . SqlQuote($milestone)); my $bugs = FetchOneColumn(); SendSQL("SELECT defaultmilestone FROM products " . - "WHERE product=" . SqlQuote($product)); + "WHERE id=$product_id"); my $defaultmilestone = FetchOneColumn(); print "
\n"; @@ -405,6 +408,7 @@ one."; if ($action eq 'delete') { PutHeader("Deleting milestone of $product"); CheckMilestone($product,$milestone); + my $product_id = get_product_id($product); # lock the tables before we start to change everything: @@ -422,7 +426,7 @@ if ($action eq 'delete') { SendSQL("SELECT bug_id FROM bugs - WHERE product=" . SqlQuote($product) . " + WHERE product_id=$product_id AND target_milestone=" . SqlQuote($milestone)); while (MoreSQLData()) { my $bugid = FetchOneColumn(); @@ -439,13 +443,13 @@ if ($action eq 'delete') { # Deleting the rest is easier: SendSQL("DELETE FROM bugs - WHERE product=" . SqlQuote($product) . " + WHERE product_id=$product_id AND target_milestone=" . SqlQuote($milestone)); print "Bugs deleted.
\n"; } SendSQL("DELETE FROM milestones - WHERE product=" . SqlQuote($product) . " + WHERE product_id=$product_id AND value=" . SqlQuote($milestone)); print "Milestone deleted.

\n"; SendSQL("UNLOCK TABLES"); @@ -466,9 +470,10 @@ if ($action eq 'delete') { if ($action eq 'edit') { PutHeader("Edit milestone of $product"); CheckMilestone($product,$milestone); + my $product_id = get_product_id($product); - SendSQL("SELECT sortkey FROM milestones WHERE product=" . - SqlQuote($product) . " AND value = " . SqlQuote($milestone)); + SendSQL("SELECT sortkey FROM milestones WHERE product_id=$product_id " . + " AND value = " . SqlQuote($milestone)); my $sortkey = FetchOneColumn(); print "
\n"; @@ -506,6 +511,7 @@ if ($action eq 'update') { my $sortkeyold = trim($::FORM{sortkeyold} || '0'); CheckMilestone($product,$milestoneold); + my $product_id = get_product_id($product); SendSQL("LOCK TABLES bugs WRITE, milestones WRITE, @@ -535,14 +541,14 @@ if ($action eq 'update') { SET target_milestone=" . SqlQuote($milestone) . ", delta_ts=delta_ts WHERE target_milestone=" . SqlQuote($milestoneold) . " - AND product=" . SqlQuote($product)); + AND product_id=$product_id"); SendSQL("UPDATE milestones SET value=" . SqlQuote($milestone) . " - WHERE product=" . SqlQuote($product) . " + WHERE product_id=$product_id AND value=" . SqlQuote($milestoneold)); SendSQL("UPDATE products " . "SET defaultmilestone = " . SqlQuote($milestone) . - "WHERE product = " . SqlQuote($product) . + " WHERE id = $product_id" . " AND defaultmilestone = " . SqlQuote($milestoneold)); unlink "data/versioncache"; print "Updated milestone.
\n"; -- cgit v1.2.3-24-g4f1b