From 5ee25d37a4ba44b021cf87273194001e8b4538e9 Mon Sep 17 00:00:00 2001 From: "bugreport%peshkin.net" Date: Fri, 2 Aug 2002 05:18:21 +0000 Subject: [PATCH] Merged in 43600 git-svn-id: svn://10.0.0.236/branches/Groups_20020716_Branch@126221 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/webtools/bugzilla/Bug.pm | 9 +- mozilla/webtools/bugzilla/CGI.pl | 4 +- mozilla/webtools/bugzilla/attachment.cgi | 4 +- mozilla/webtools/bugzilla/bug_form.pl | 14 +- mozilla/webtools/bugzilla/buglist.cgi | 54 ++++- mozilla/webtools/bugzilla/checksetup.pl | 227 +++++++++++++----- mozilla/webtools/bugzilla/collectstats.pl | 5 +- .../webtools/bugzilla/describecomponents.cgi | 8 +- mozilla/webtools/bugzilla/duplicates.cgi | 20 +- .../webtools/bugzilla/editattachstatuses.cgi | 32 +-- mozilla/webtools/bugzilla/editcomponents.cgi | 113 ++++----- mozilla/webtools/bugzilla/editgroups.cgi | 4 +- mozilla/webtools/bugzilla/editmilestones.cgi | 48 ++-- mozilla/webtools/bugzilla/editproducts.cgi | 121 +++++----- mozilla/webtools/bugzilla/editusers.cgi | 14 +- mozilla/webtools/bugzilla/editversions.cgi | 66 ++--- mozilla/webtools/bugzilla/enter_bug.cgi | 10 +- mozilla/webtools/bugzilla/globals.pl | 63 ++++- mozilla/webtools/bugzilla/importxml.pl | 7 +- mozilla/webtools/bugzilla/long_list.cgi | 9 +- mozilla/webtools/bugzilla/post_bug.cgi | 27 ++- mozilla/webtools/bugzilla/process_bug.cgi | 66 ++++- mozilla/webtools/bugzilla/processmail | 2 +- mozilla/webtools/bugzilla/queryhelp.cgi | 8 +- mozilla/webtools/bugzilla/reports.cgi | 14 +- mozilla/webtools/bugzilla/sanitycheck.cgi | 52 ++-- mozilla/webtools/bugzilla/votes.cgi | 11 +- 27 files changed, 629 insertions(+), 383 deletions(-) diff --git a/mozilla/webtools/bugzilla/Bug.pm b/mozilla/webtools/bugzilla/Bug.pm index df7a9155368..d73bc536f9f 100755 --- a/mozilla/webtools/bugzilla/Bug.pm +++ b/mozilla/webtools/bugzilla/Bug.pm @@ -111,13 +111,16 @@ sub initBug { my $query = " select - bugs.bug_id, alias, product, version, rep_platform, op_sys, bug_status, - resolution, priority, bug_severity, component, assigned_to, reporter, + bugs.bug_id, alias, products.name, version, rep_platform, op_sys, bug_status, + resolution, priority, bug_severity, components.name, assigned_to, reporter, bug_file_loc, short_desc, target_milestone, qa_contact, status_whiteboard, date_format(creation_ts,'%Y-%m-%d %H:%i'), groupset, delta_ts, sum(votes.count) - from bugs left join votes using(bug_id) + from bugs left join votes using(bug_id), + products, components where bugs.bug_id = $bug_id + AND products.id = bugs.product_id + AND components.id = bugs.component_id group by bugs.bug_id"; &::SendSQL(&::SelectVisible($query, $user_id, $usergroupset)); diff --git a/mozilla/webtools/bugzilla/CGI.pl b/mozilla/webtools/bugzilla/CGI.pl index aa7236c11b4..f18c85a5065 100644 --- a/mozilla/webtools/bugzilla/CGI.pl +++ b/mozilla/webtools/bugzilla/CGI.pl @@ -552,7 +552,7 @@ sub GetUserInfo { sub CheckEmailSyntax { my ($addr) = (@_); my $match = Param('emailregexp'); - if ($addr !~ /$match/ || $addr =~ /[\\\(\)<>&,;:"\[\] \t\r\n]/) { + if ($addr !~ /$match/ || $addr =~ /[\\\(\)<>&,;:\"\[\] \t\r\n]/) { ThrowUserError("The e-mail address you entered(" . html_quote($addr) . ") didn't pass our syntax checking for a legal email address. " . Param('emailregexpdesc') . @@ -948,7 +948,7 @@ sub CheckIfVotedConfirmed { SendSQL("SELECT bugs.votes, bugs.bug_status, products.votestoconfirm, " . " bugs.everconfirmed " . "FROM bugs, products " . - "WHERE bugs.bug_id = $id AND products.product = bugs.product"); + "WHERE bugs.bug_id = $id AND products.product_id = bugs.product_id"); my ($votes, $status, $votestoconfirm, $everconfirmed) = (FetchSQLData()); if ($votes >= $votestoconfirm && $status eq $::unconfirmedstate) { SendSQL("UPDATE bugs SET bug_status = 'NEW', everconfirmed = 1 " . diff --git a/mozilla/webtools/bugzilla/attachment.cgi b/mozilla/webtools/bugzilla/attachment.cgi index 12ec3b9f74b..cb08a92d36f 100755 --- a/mozilla/webtools/bugzilla/attachment.cgi +++ b/mozilla/webtools/bugzilla/attachment.cgi @@ -251,7 +251,7 @@ sub validateStatuses FROM attachments, bugs, attachstatusdefs WHERE attachments.attach_id = $::FORM{'id'} AND attachments.bug_id = bugs.bug_id - AND attachstatusdefs.product = bugs.product"); + AND attachstatusdefs.product_id = bugs.product_id"); my @statusdefs; push(@statusdefs, FetchSQLData()) while MoreSQLData(); PopGlobalSQLState(); @@ -572,7 +572,7 @@ sub edit SendSQL("SELECT id, name FROM attachstatusdefs, bugs WHERE bug_id = $bugid - AND attachstatusdefs.product = bugs.product + AND attachstatusdefs.product_id = bugs.product_id ORDER BY sortkey"); while ( MoreSQLData() ) { diff --git a/mozilla/webtools/bugzilla/bug_form.pl b/mozilla/webtools/bugzilla/bug_form.pl index 036c1c07b79..2fd1ef492e1 100644 --- a/mozilla/webtools/bugzilla/bug_form.pl +++ b/mozilla/webtools/bugzilla/bug_form.pl @@ -77,18 +77,26 @@ sub show_bug { # Populate the bug hash with the info we get directly from the DB. my $query = " - SELECT bugs.bug_id, alias, product, version, rep_platform, + SELECT bugs.bug_id, alias, products.name, version, rep_platform, op_sys, bug_status, resolution, priority, - bug_severity, component, assigned_to, reporter, + bug_severity, components.name, assigned_to, reporter, bug_file_loc, short_desc, target_milestone, qa_contact, status_whiteboard, date_format(creation_ts,'%Y-%m-%d %H:%i'), delta_ts, sum(votes.count) - FROM bugs LEFT JOIN votes USING(bug_id) + FROM bugs LEFT JOIN votes USING(bug_id), products, components WHERE bugs.bug_id = $id + AND bugs.product_id = products.id + AND bugs.component_id = components.id GROUP BY bugs.bug_id"; SendSQL($query); + + # The caller is meant to have checked this. Abort here so that + # we don't get obscure SQL errors, below + if (!MoreSQLData()) { + ThrowCodeError("No data when fetching bug $id"); + } my $value; my @row = FetchSQLData(); diff --git a/mozilla/webtools/bugzilla/buglist.cgi b/mozilla/webtools/bugzilla/buglist.cgi index 7fcdf8650ed..3fea497d0f9 100755 --- a/mozilla/webtools/bugzilla/buglist.cgi +++ b/mozilla/webtools/bugzilla/buglist.cgi @@ -328,13 +328,29 @@ sub GenerateSQL { # First, deal with all the old hard-coded non-chart-based poop. - unshift(@supptables, - ("profiles map_assigned_to", - "profiles map_reporter", - "LEFT JOIN profiles map_qa_contact ON bugs.qa_contact = map_qa_contact.userid")); - unshift(@wherepart, - ("bugs.assigned_to = map_assigned_to.userid", - "bugs.reporter = map_reporter.userid")); + if (lsearch($fieldsref, 'map_assigned_to.login_name') >= 0) { + push @supptables, "profiles AS map_assigned_to"; + push @wherepart, "bugs.assigned_to = map_assigned_to.userid"; + } + + if (lsearch($fieldsref, 'map_reporter.login_name') >= 0) { + push @supptables, "profiles AS map_reporter"; + push @wherepart, "bugs.assigned_to = map_reporter.userid"; + } + + if (lsearch($fieldsref, 'map_qa_contact.login_name') >= 0) { + push @supptables, "LEFT JOIN profiles map_qa_contact ON bugs.qa_contact = map_qa_contact.userid"; + } + + if (lsearch($fieldsref, 'map_products.name') >= 0) { + push @supptables, "products AS map_products"; + push @wherepart, "bugs.product_id = map_products.id"; + } + + if (lsearch($fieldsref, 'map_components.name') >= 0) { + push @supptables, "components AS map_components"; + push @wherepart, "bugs.component_id = map_components.id"; + } my $minvotes; if (defined $F{'votes'}) { @@ -368,9 +384,9 @@ sub GenerateSQL { # push(@wherepart, "( $F{'sql'} )"); # } - my @legal_fields = ("product", "version", "rep_platform", "op_sys", + my @legal_fields = ("version", "rep_platform", "op_sys", "bug_status", "resolution", "priority", "bug_severity", - "assigned_to", "reporter", "component", + "assigned_to", "reporter", "target_milestone"); foreach my $field (keys %F) { @@ -380,6 +396,18 @@ sub GenerateSQL { } } + if ($F{'product'}) { + push(@supptables, "products products_"); + push(@wherepart, "products_.id = bugs.product_id"); + push(@specialchart, ["products_.name", "anyexact", $F{'product'}]); + } + + if ($F{'component'}) { + push(@supptables, "components components_"); + push(@wherepart, "components_.id = bugs.component_id"); + push(@specialchart, ["components_.name", "anyexact", $F{'component'}]); + } + if ($F{'keywords'}) { my $t = $F{'keywords_type'}; if (!$t || $t eq "or") { @@ -525,7 +553,7 @@ sub GenerateSQL { my @funcdefs = ( "^(assigned_to|reporter)," => sub { - push(@supptables, "profiles map_$f"); + push(@supptables, "profiles AS map_$f"); push(@wherepart, "bugs.$f = map_$f.userid"); $f = "map_$f.login_name"; }, @@ -1220,8 +1248,8 @@ DefineColumn("resolution" , "bugs.resolution" , "Result" DefineColumn("summary" , "bugs.short_desc" , "Summary" ); DefineColumn("summaryfull" , "bugs.short_desc" , "Summary" ); DefineColumn("status_whiteboard" , "bugs.status_whiteboard" , "Status Summary" ); -DefineColumn("component" , "bugs.component" , "Component" ); -DefineColumn("product" , "bugs.product" , "Product" ); +DefineColumn("component" , "map_components.name" , "Component" ); +DefineColumn("product" , "map_products.name" , "Product" ); DefineColumn("version" , "bugs.version" , "Version" ); DefineColumn("os" , "bugs.op_sys" , "OS" ); DefineColumn("target_milestone" , "bugs.target_milestone" , "Target Milestone" ); @@ -1377,7 +1405,7 @@ if ($order) { # change it to order by the sortkey of the target_milestone first. if ($db_order =~ /bugs.target_milestone/) { $db_order =~ s/bugs.target_milestone/ms_order.sortkey,ms_order.value/; - $query =~ s/\sWHERE\s/ LEFT JOIN milestones ms_order ON ms_order.value = bugs.target_milestone AND ms_order.product = bugs.product WHERE /; + $query =~ s/\sWHERE\s/ LEFT JOIN milestones ms_order ON ms_order.value = bugs.target_milestone AND ms_order.product_id = bugs.product_id WHERE /; } # If we are sorting by votes, sort in descending order if no explicit diff --git a/mozilla/webtools/bugzilla/checksetup.pl b/mozilla/webtools/bugzilla/checksetup.pl index 98a8ab1bce0..e96bc6974be 100755 --- a/mozilla/webtools/bugzilla/checksetup.pl +++ b/mozilla/webtools/bugzilla/checksetup.pl @@ -23,6 +23,8 @@ # Dan Mosedale # Dave Miller # Zach Lipton +# Jacob Steenhagen +# Bradley Baetz # # # Direct any questions on this source code to @@ -1324,7 +1326,7 @@ $table{attachstatusdefs} = name VARCHAR(50) NOT NULL , description MEDIUMTEXT NULL , sortkey SMALLINT NOT NULL DEFAULT 0 , - product VARCHAR(64) NOT NULL + product_id SMALLINT NOT NULL '; # @@ -1342,11 +1344,11 @@ $table{bugs} = short_desc mediumtext, op_sys enum($my_opsys) not null, priority enum($my_priorities) not null, - product varchar(64) not null, + product_id smallint not null, rep_platform enum($my_platforms), reporter mediumint not null, version varchar(64) not null, - component varchar(50) not null, + component_id smallint not null, resolution enum("", "FIXED", "INVALID", "WONTFIX", "LATER", "REMIND", "DUPLICATE", "WORKSFORME", "MOVED") not null, target_milestone varchar(20) not null default "---", qa_contact mediumint not null, @@ -1368,10 +1370,10 @@ $table{bugs} = index (bug_status), index (op_sys), index (priority), - index (product), + index (product_id), index (reporter), index (version), - index (component), + index (component_id), index (resolution), index (target_milestone), index (qa_contact), @@ -1407,11 +1409,15 @@ $table{longdescs} = $table{components} = - 'value tinytext, - program varchar(64), + 'id smallint not null auto_increment primary key, + name varchar(64) not null, + product_id smallint not null, initialowner mediumint not null, initialqacontact mediumint not null, - description mediumtext not null'; + description mediumtext not null, + + unique(product_id,name), + index(name)'; $table{dependencies} = @@ -1457,16 +1463,17 @@ $table{logincookies} = $table{products} = - 'product_id mediumint primary key auto_increment not null, - product varchar(64), + 'id smallint not null auto_increment primary key, + name varchar(64) not null, description mediumtext, milestoneurl tinytext not null, disallownew tinyint not null, votesperuser smallint not null, maxvotesperbug smallint not null default 10000, votestoconfirm smallint not null, - defaultmilestone varchar(20) not null default "---" -'; + defaultmilestone varchar(20) not null default "---", + + unique(name)'; $table{profiles} = @@ -1515,7 +1522,7 @@ $table{fielddefs} = $table{versions} = 'value tinytext, - program varchar(64) not null'; + product_id smallint not null'; $table{votes} = @@ -1542,10 +1549,10 @@ $table{keyworddefs} = $table{milestones} = - 'value varchar(20) not null, - product varchar(64) not null, + 'product_id smallint not null, + value varchar(20) not null, sortkey smallint not null, - unique (product, value)'; + unique (product_id, value)'; $table{shadowlog} = 'id int not null auto_increment primary key, @@ -2167,22 +2174,27 @@ _End_Of_SQL_ $sth->execute; my ($adminuid) = $sth->fetchrow_array; if (!$adminuid) { die "No administator!" } # should never get here -$sth = $dbh->prepare("SELECT product FROM products"); +$sth = $dbh->prepare("SELECT description FROM products"); $sth->execute; unless ($sth->rows) { print "Creating initial dummy product 'TestProduct' ...\n"; - $dbh->do('INSERT INTO products(product, description, milestoneurl, disallownew, votesperuser, votestoconfirm) VALUES ("TestProduct", + $dbh->do('INSERT INTO products(name, description, milestoneurl, disallownew, votesperuser, votestoconfirm) VALUES ("TestProduct", "This is a test product. This ought to be blown away and ' . 'replaced with real stuff in a finished installation of ' . 'bugzilla.", "", 0, 0, 0)'); - $dbh->do('INSERT INTO versions (value, program) VALUES ("other", "TestProduct")'); - $dbh->do("INSERT INTO components (value, program, description, initialowner, initialqacontact) + # We could probably just assume that this is "1", but better + # safe than sorry... + $sth = $dbh->prepare("SELECT LAST_INSERT_ID()"); + $sth->execute; + my ($product_id) = $sth->fetchrow_array; + $dbh->do(qq{INSERT INTO versions (value, product_id) VALUES ("other", $product_id)}); + $dbh->do("INSERT INTO components (name, product_id, description, initialowner, initialqacontact) VALUES (" . - "'TestComponent', 'TestProduct', " . + "'TestComponent', $product_id, " . "'This is a test component in the test product database. " . "This ought to be blown away and replaced with real stuff in " . "a finished installation of bugzilla.', $adminuid, 0)"); - $dbh->do('INSERT INTO milestones (product, value) VALUES ("TestProduct","---")'); + $dbh->do(qq{INSERT INTO milestones (product_id, value) VALUES ($product_id,"---")}); } @@ -2295,8 +2307,6 @@ AddField('products', 'disallownew', 'tinyint not null'); AddField('products', 'milestoneurl', 'tinytext not null'); AddField('components', 'initialqacontact', 'tinytext not null'); AddField('components', 'description', 'mediumtext not null'); -ChangeFieldType('components', 'program', 'varchar(64)'); - # 1999-06-22 Added an entry to the attachments table to record who the # submitter was. Nothing uses this yet, but it still should be recorded. @@ -2347,10 +2357,14 @@ AddField('products', 'votesperuser', 'mediumint not null'); # tinytext is equivalent to varchar(255), which is quite huge, so I change # them all to varchar(64). -ChangeFieldType ('bugs', 'product', 'varchar(64) not null'); -ChangeFieldType ('components', 'program', 'varchar(64)'); -ChangeFieldType ('products', 'product', 'varchar(64)'); -ChangeFieldType ('versions', 'program', 'varchar(64) not null'); +# Only do this if these fields still exist - they're removed below, in +# a later change +if (GetFieldDef('products', 'product')) { + ChangeFieldType ('bugs', 'product', 'varchar(64) not null'); + ChangeFieldType ('components', 'program', 'varchar(64)'); + ChangeFieldType ('products', 'product', 'varchar(64)'); + ChangeFieldType ('versions', 'program', 'varchar(64) not null'); +} # 2000-01-16 Added a "keywords" field to the bugs table, which # contains a string copy of the entries of the keywords table for this @@ -3101,13 +3115,134 @@ if (!GetFieldDef("bugs", "alias")) { $dbh->do("ALTER TABLE bugs ADD UNIQUE (alias)"); } +# 2002-07-15 davef@tetsubo.com - bug 67950 +# Move quips to the db. +my $renamed_comments_file = 0; +if (GetFieldDef("quips", "quipid")) { + if (-e 'data/comments' && open (COMMENTS, ") { + chomp; + $dbh->do("INSERT INTO quips (quip) VALUES (" + . $dbh->quote($_) . ")"); + } + print "The data/comments file (used to store quips) has been + copied into the database, and the data/comments file + moved to data/comments.bak - you can delete this file + once you're satisfied the migration worked correctly.\n\n"; + close COMMENTS; + rename("data/comments", "data/comments.bak") or next; + $renamed_comments_file = 1; + } +} + +# Warn if data/comments.bak exists, as it should be deleted. +if (-e 'data/comments.bak' && !$renamed_comments_file) { + print "The data/comments.bak file can be removed, as it's no longer + used.\n\n"; +} + +# 2002-07-31 bbaetz@student.usyd.edu.au bug 158236 +# Remove unused column +if (GetFieldDef("namedqueries", "watchfordiffs")) { + DropField("namedqueries", "watchfordiffs"); +} + +# 2002-08-?? jake@acutex.net/bbaetz@student.usyd.edu.au - bug 43600 +# Use integer IDs for products and components. +if (GetFieldDef("products", "product")) { + print "Updating database to use product IDs.\n"; + + # First, we need to remove possible NULL entries + # NULLs may exist, but won't have been used, since all the uses of them + # are in NOT NULL fields in other tables + $dbh->do("DELETE FROM products WHERE product IS NULL"); + $dbh->do("DELETE FROM components WHERE value IS NULL"); + + AddField("products", "id", "smallint not null auto_increment primary key"); + AddField("components", "product_id", "smallint not null"); + AddField("versions", "product_id", "smallint not null"); + AddField("milestones", "product_id", "smallint not null"); + AddField("bugs", "product_id", "smallint not null"); + AddField("attachstatusdefs", "product_id", "smallint not null"); + my %products; + my $sth = $dbh->prepare("SELECT id, product FROM products"); + $sth->execute; + while (my ($product_id, $product) = $sth->fetchrow_array()) { + if (exists $products{$product}) { + print "Ignoring duplicate product $product\n"; + $dbh->do("DELETE FROM products WHERE id = $product_id"); + next; + } + $products{$product} = 1; + $dbh->do("UPDATE components SET product_id = $product_id " . + "WHERE program = " . $dbh->quote($product)); + $dbh->do("UPDATE versions SET product_id = $product_id " . + "WHERE program = " . $dbh->quote($product)); + $dbh->do("UPDATE milestones SET product_id = $product_id " . + "WHERE product = " . $dbh->quote($product)); + $dbh->do("UPDATE bugs SET product_id = $product_id, delta_ts=delta_ts " . + "WHERE product = " . $dbh->quote($product)); + $dbh->do("UPDATE attachstatusdefs SET product_id = $product_id " . + "WHERE product = " . $dbh->quote($product)); + } + + print "Updating the database to use component IDs.\n"; + AddField("components", "id", "smallint not null auto_increment primary key"); + AddField("bugs", "component_id", "smallint not null"); + my %components; + $sth = $dbh->prepare("SELECT id, value, product_id FROM components"); + $sth->execute; + while (my ($component_id, $component, $product_id) = $sth->fetchrow_array()) { + if (exists $components{$component}) { + if (exists $components{$component}{$product_id}) { + print "Ignoring duplicate component $component for product $product_id\n"; + $dbh->do("DELETE FROM components WHERE id = $component_id"); + next; + } + } else { + $components{$component} = {}; + } + $components{$component}{$product_id} = 1; + $dbh->do("UPDATE bugs SET component_id = $component_id, delta_ts=delta_ts " . + "WHERE component = " . $dbh->quote($component) . + " AND product_id = $product_id"); + } + print "Fixing Indexes and Uniqueness.\n"; + $dbh->do("ALTER TABLE milestones DROP INDEX product"); + $dbh->do("ALTER TABLE milestones ADD UNIQUE (product_id, value)"); + $dbh->do("ALTER TABLE bugs DROP INDEX product"); + $dbh->do("ALTER TABLE bugs ADD INDEX (product_id)"); + $dbh->do("ALTER TABLE bugs DROP INDEX component"); + $dbh->do("ALTER TABLE bugs ADD INDEX (component_id)"); + print "Fixing fielddefs table.\n"; + $dbh->do("UPDATE fielddefs SET name = 'product_id' WHERE name = 'product'"); + $dbh->do("UPDATE fielddefs SET name = 'component_id' WHERE name = 'component'"); + + print "Removing, renaming, and retyping old product and component fields.\n"; + DropField("components", "program"); + DropField("versions", "program"); + DropField("milestones", "product"); + DropField("bugs", "product"); + DropField("bugs", "component"); + DropField("attachstatusdefs", "product"); + RenameField("products", "product", "name"); + ChangeFieldType("products", "name", "varchar(64) not null"); + RenameField("components", "value", "name"); + ChangeFieldType("components", "name", "varchar(64) not null"); + + print "Adding indexes for products and components tables.\n"; + $dbh->do("ALTER TABLE products ADD UNIQUE (name)"); + $dbh->do("ALTER TABLE components ADD UNIQUE (product_id, name)"); + $dbh->do("ALTER TABLE components ADD INDEX (name)"); +} + + # # If the whole groups system is new, but the installation isn't, # convert all the old groupset groups, etc... if (GetFieldDef("profiles", "groupset")) { AddField('groups', 'group_when', 'datetime not null'); - AddField('products', 'product_id', - 'mediumint primary key auto_increment not null'); AddField('profiles', 'profile_when', 'datetime not null'); AddField('profiles', 'refreshed_when', 'datetime not null'); @@ -3149,38 +3284,6 @@ if (GetFieldDef("profiles", "groupset")) { DropField('groups','bit'); } -# 2002-07-15 davef@tetsubo.com - bug 67950 -# Move quips to the db. -my $renamed_comments_file = 0; -if (GetFieldDef("quips", "quipid")) { - if (-e 'data/comments' && open (COMMENTS, ") { - chomp; - $dbh->do("INSERT INTO quips (quip) VALUES (" - . $dbh->quote($_) . ")"); - } - print "The data/comments file (used to store quips) has been - copied into the database, and the data/comments file - moved to data/comments.bak - you can delete this file - once you're satisfied the migration worked correctly.\n\n"; - close COMMENTS; - rename("data/comments", "data/comments.bak") or next; - $renamed_comments_file = 1; - } -} - -# Warn if data/comments.bak exists, as it should be deleted. -if (-e 'data/comments.bak' && !$renamed_comments_file) { - print "The data/comments.bak file can be removed, as it's no longer - used.\n\n"; -} - -# 2002-07-31 bbaetz@student.usyd.edu.au bug 158236 -# Remove unused column -if (GetFieldDef("namedqueries", "watchfordiffs")) { - DropField("namedqueries", "watchfordiffs"); -} # If you had to change the --TABLE-- definition in any way, then add your # differential change code *** A B O V E *** this comment. diff --git a/mozilla/webtools/bugzilla/collectstats.pl b/mozilla/webtools/bugzilla/collectstats.pl index 4e69ab9b5fb..3f40c4c22eb 100755 --- a/mozilla/webtools/bugzilla/collectstats.pl +++ b/mozilla/webtools/bugzilla/collectstats.pl @@ -67,6 +67,7 @@ sub collect_stats { my $dir = shift; my $product = shift; my $when = localtime (time); + my $product_id = get_product_id($product) unless $product eq '-All-'; # NB: Need to mangle the product for the filename, but use the real # product name in the query @@ -82,7 +83,7 @@ sub collect_stats { if( $product eq "-All-" ) { SendSQL("select count(bug_status) from bugs where bug_status='$status'"); } else { - SendSQL("select count(bug_status) from bugs where bug_status='$status' and product='$product'"); + SendSQL("select count(bug_status) from bugs where bug_status='$status' and product_id=$product_id"); } push @row, FetchOneColumn(); @@ -92,7 +93,7 @@ sub collect_stats { if( $product eq "-All-" ) { SendSQL("select count(resolution) from bugs where resolution='$resolution'"); } else { - SendSQL("select count(resolution) from bugs where resolution='$resolution' and product='$product'"); + SendSQL("select count(resolution) from bugs where resolution='$resolution' and product_id=$product_id"); } push @row, FetchOneColumn(); diff --git a/mozilla/webtools/bugzilla/describecomponents.cgi b/mozilla/webtools/bugzilla/describecomponents.cgi index 2f723757e73..be2820fe810 100755 --- a/mozilla/webtools/bugzilla/describecomponents.cgi +++ b/mozilla/webtools/bugzilla/describecomponents.cgi @@ -89,6 +89,8 @@ grep($product eq $_ , @::legal_product) || DisplayError("The product name is invalid.") && exit; +my $product_id = get_product_id($product); + # Make sure the user is authorized to access this product. if (Param("usebuggroups") && GroupExists($product)) { confirm_login() unless $::userid; @@ -102,9 +104,9 @@ if (Param("usebuggroups") && GroupExists($product)) { ###################################################################### my @components; -SendSQL("SELECT value, initialowner, initialqacontact, description FROM " . - "components WHERE program = " . SqlQuote($product) . " ORDER BY " . - "value"); +SendSQL("SELECT name, initialowner, initialqacontact, description FROM " . + "components WHERE product_id = $product_id ORDER BY " . + "name"); while (MoreSQLData()) { my ($name, $initialowner, $initialqacontact, $description) = FetchSQLData(); diff --git a/mozilla/webtools/bugzilla/duplicates.cgi b/mozilla/webtools/bugzilla/duplicates.cgi index 39f1b82ad8c..fdf8968d706 100755 --- a/mozilla/webtools/bugzilla/duplicates.cgi +++ b/mozilla/webtools/bugzilla/duplicates.cgi @@ -62,6 +62,15 @@ my $product = formvalue("product"); my $sortvisible = formvalue("sortvisible"); my @buglist = (split(/[:,]/, formvalue("bug_id"))); +my $product_id; +if ($product) { + $product_id = get_product_id($product); + if (!$product_id) { + ThrowUserError("The product " . html_quote($product) . + " does not exist"); + } +} + # Small backwards-compatibility hack, dated 2002-04-10. $sortby = "count" if $sortby eq "dup_count"; @@ -139,16 +148,17 @@ if (!tie(%before, 'AnyDBM_File', "data/duplicates/dupes$whenever", # WONTFIX. We want to see VERIFIED INVALID and WONTFIX because common # "bugs" which aren't bugs end up in this state. my $query = " - SELECT bugs.bug_id, component, bug_severity, op_sys, target_milestone, + SELECT bugs.bug_id, components.name, bug_severity, op_sys, target_milestone, short_desc, bug_status, resolution - FROM bugs - WHERE (bug_status != 'CLOSED') + FROM bugs, components + WHERE (bugs.component_id = components.id) + AND (bug_status != 'CLOSED') AND ((bug_status = 'VERIFIED' AND resolution IN ('INVALID', 'WONTFIX')) OR (bug_status != 'VERIFIED')) AND bugs.bug_id IN (" . join(", ", keys %count) . ")"; -# Limit to a single product if requested -$query .= (" AND product = " . SqlQuote($product)) if $product; +# Limit to a single product if requested +$query .= (" AND product_id = $product_id") if $product_id; SendSQL($query, $::userid); diff --git a/mozilla/webtools/bugzilla/editattachstatuses.cgi b/mozilla/webtools/bugzilla/editattachstatuses.cgi index 910379b99cd..ff78221813a 100755 --- a/mozilla/webtools/bugzilla/editattachstatuses.cgi +++ b/mozilla/webtools/bugzilla/editattachstatuses.cgi @@ -155,7 +155,7 @@ sub validateSortKey sub validateProduct { # Retrieve a list of products. - SendSQL("SELECT product FROM products"); + SendSQL("SELECT name FROM products"); my @products; push(@products, FetchSQLData()) while MoreSQLData(); @@ -180,11 +180,13 @@ sub list # Retrieve a list of attachment status flags and create an array of hashes # in which each hash contains the data for one flag. - SendSQL("SELECT id, name, description, sortkey, product, count(statusid) - FROM attachstatusdefs LEFT JOIN attachstatuses - ON attachstatusdefs.id=attachstatuses.statusid - GROUP BY id - ORDER BY sortkey"); + SendSQL("SELECT attachstatusdefs.id, attachstatusdefs.name, " . + "attachstatusdefs.description, attachstatusdefs.sortkey, products.name, " . + "count(attachstatusdefs.id) " . + "FROM attachstatusdefs, products " . + "WHERE products.id = attachstatusdefs.product_id " . + "GROUP BY id " . + "ORDER BY attachstatusdefs.sortkey"); my @statusdefs; while ( MoreSQLData() ) { @@ -212,7 +214,7 @@ sub create # Display a form for creating a new attachment status flag. # Retrieve a list of products to which the attachment status may apply. - SendSQL("SELECT product FROM products"); + SendSQL("SELECT name FROM products"); my @products; push(@products, FetchSQLData()) while MoreSQLData(); @@ -236,14 +238,13 @@ sub insert # in a SQL statement. my $name = SqlQuote($::FORM{'name'}); my $desc = SqlQuote($::FORM{'desc'}); - my $product = SqlQuote($::FORM{'product'}); + my $product_id = get_product_id($::FORM{'product'}); SendSQL("LOCK TABLES attachstatusdefs WRITE"); SendSQL("SELECT MAX(id) FROM attachstatusdefs"); - my $id = FetchSQLData() || 0; - $id++; - SendSQL("INSERT INTO attachstatusdefs (id, name, description, sortkey, product) - VALUES ($id, $name, $desc, $::FORM{'sortkey'}, $product)"); + my $id = FetchSQLData() + 1; + SendSQL("INSERT INTO attachstatusdefs (id, name, description, sortkey, product_id) + VALUES ($id, $name, $desc, $::FORM{'sortkey'}, $product_id)"); SendSQL("UNLOCK TABLES"); # Display the "administer attachment status flags" page @@ -257,8 +258,11 @@ sub edit # Display a form for editing an existing attachment status flag. # Retrieve the definition from the database. - SendSQL("SELECT name, description, sortkey, product - FROM attachstatusdefs WHERE id = $::FORM{'id'}"); + SendSQL("SELECT attachstatusdefs.name, attachstatusdefs.description, " . + " attachstatusdefs.sortkey, products.name " . + "FROM attachstatusdefs, products " . + "WHERE attachstatusdefs.product_id = products.id " . + " AND attachstatusdefs.id = $::FORM{'id'}"); my ($name, $desc, $sortkey, $product) = FetchSQLData(); # Define the variables and functions that will be passed to the UI template. diff --git a/mozilla/webtools/bugzilla/editcomponents.cgi b/mozilla/webtools/bugzilla/editcomponents.cgi index 576f013759c..10a610f951c 100755 --- a/mozilla/webtools/bugzilla/editcomponents.cgi +++ b/mozilla/webtools/bugzilla/editcomponents.cgi @@ -55,9 +55,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(); } @@ -84,9 +84,10 @@ sub TestComponent ($$) my ($prod,$comp) = @_; # does the product exist? - SendSQL("SELECT program,value - FROM components - WHERE program=" . SqlQuote($prod) . " and value=" . SqlQuote($comp)); + SendSQL("SELECT components.name + FROM components, products + WHERE products.id = components.product_id + AND products.name=" . SqlQuote($prod) . " AND components.name=" . SqlQuote($comp)); return FetchOneColumn(); } @@ -225,15 +226,14 @@ unless ($product) { PutHeader("Select product"); if ($dobugcounts){ - SendSQL("SELECT products.product,products.description,COUNT(bug_id) - FROM products LEFT JOIN bugs - ON products.product=bugs.product - GROUP BY products.product - ORDER BY products.product"); + SendSQL("SELECT products.name,products.description,COUNT(bug_id) + FROM products LEFT JOIN bugs ON products.id = bugs.product_id + GROUP BY products.name + ORDER BY products.name"); } else { - SendSQL("SELECT products.product,products.description + SendSQL("SELECT products.name,products.description FROM products - ORDER BY products.product"); + ORDER BY products.name"); } print "\n"; print " \n"; @@ -270,18 +270,18 @@ unless ($product) { unless ($action) { PutHeader("Select component of $product"); CheckProduct($product); + my $product_id = get_product_id($product); if ($dobugcounts) { - SendSQL("SELECT value,description,initialowner,initialqacontact,COUNT(bug_id) - FROM components LEFT JOIN bugs - ON components.program=bugs.product AND components.value=bugs.component - WHERE program=" . SqlQuote($product) . " - GROUP BY value"); + SendSQL("SELECT name,description,initialowner,initialqacontact,COUNT(bug_id) + FROM components LEFT JOIN bugs ON components.id = bugs.component_id + WHERE components.product_id=$product_id + GROUP BY name"); } else { - SendSQL("SELECT value,description,initialowner,initialqacontact + SendSQL("SELECT name,description,initialowner,initialqacontact FROM components - WHERE program=" . SqlQuote($product) . " - GROUP BY value"); + WHERE product_id=$product_id + GROUP BY name"); } print "
Edit components of ...
\n"; print " \n"; @@ -370,6 +370,7 @@ if ($action eq 'add') { if ($action eq 'new') { PutHeader("Adding new component of $product"); CheckProduct($product); + my $product_id = get_product_id($product); # Cleanups and valididy checks @@ -426,9 +427,9 @@ if ($action eq 'new') { # Add the new component SendSQL("INSERT INTO components ( " . - "program, value, description, initialowner, initialqacontact " . + "product_id, name, description, initialowner, initialqacontact " . " ) VALUES ( " . - SqlQuote($product) . "," . + $product_id . "," . SqlQuote($component) . "," . SqlQuote($description) . "," . SqlQuote($initialownerid) . "," . @@ -457,20 +458,20 @@ if ($action eq 'new') { if ($action eq 'del') { PutHeader("Delete component of $product"); CheckComponent($product, $component); + my $component_id = get_component_id($product, $component); # display some data about the component - SendSQL("SELECT products.product,products.description, + SendSQL("SELECT products.name,products.description, products.milestoneurl,products.disallownew, - components.program,components.value,components.initialowner, + components.name,components.initialowner, components.initialqacontact,components.description FROM products - LEFT JOIN components on product=program - WHERE product=" . SqlQuote($product) . " - AND value=" . SqlQuote($component) ); + LEFT JOIN components ON products.id = components.product_id + WHERE components.id = $component_id"); my ($product,$pdesc,$milestoneurl,$disallownew, - $dummy,$component,$initialownerid,$initialqacontactid,$cdesc) = FetchSQLData(); + $component,$initialownerid,$initialqacontactid,$cdesc) = FetchSQLData(); my $initialowner = $initialownerid ? DBID_to_name ($initialownerid) : "missing"; my $initialqacontact = $initialqacontactid ? DBID_to_name ($initialqacontactid) : "missing"; @@ -503,8 +504,7 @@ if ($action eq 'del') { } SendSQL("SELECT count(bug_id) FROM bugs - WHERE product=" . SqlQuote($product) . " - AND component=" . SqlQuote($component)); + WHERE component_id = $component_id"); print "\n"; print " \n"; @@ -574,6 +574,7 @@ one."; if ($action eq 'delete') { PutHeader("Deleting component of $product"); CheckComponent($product,$component); + my $component_id = get_component_id($product,$component); # lock the tables before we start to change everything: @@ -590,8 +591,7 @@ if ($action eq 'delete') { if (Param("allowbugdeletion")) { SendSQL("SELECT bug_id FROM bugs - WHERE product=" . SqlQuote($product) . " - AND component=" . SqlQuote($component)); + WHERE component_id=$component_id"); while (MoreSQLData()) { my $bugid = FetchOneColumn(); @@ -607,14 +607,12 @@ if ($action eq 'delete') { # Deleting the rest is easier: SendSQL("DELETE FROM bugs - WHERE product=" . SqlQuote($product) . " - AND component=" . SqlQuote($component)); + WHERE component_id=$component_id"); print "Bugs deleted.
\n"; } SendSQL("DELETE FROM components - WHERE program=" . SqlQuote($product) . " - AND value=" . SqlQuote($component)); + WHERE id=$component_id"); print "Components deleted.

\n"; SendSQL("UNLOCK TABLES"); @@ -634,19 +632,18 @@ if ($action eq 'delete') { if ($action eq 'edit') { PutHeader("Edit component of $product"); CheckComponent($product,$component); + my $component_id = get_component_id($product,$component); # get data of component - SendSQL("SELECT products.product,products.description, + SendSQL("SELECT products.name,products.description, products.milestoneurl,products.disallownew, - components.program,components.value,components.initialowner, + components.name,components.initialowner, components.initialqacontact,components.description - FROM products - LEFT JOIN components on product=program - WHERE product=" . SqlQuote($product) . " - AND value=" . SqlQuote($component) ); + FROM products LEFT JOIN components ON products.id = components.product_id + WHERE components.id = $component_id"); my ($product,$pdesc,$milestoneurl,$disallownew, - $dummy,$component,$initialownerid,$initialqacontactid,$cdesc) = FetchSQLData(); + $component,$initialownerid,$initialqacontactid,$cdesc) = FetchSQLData(); my $initialowner = $initialownerid ? DBID_to_name ($initialownerid) : ''; my $initialqacontact = $initialqacontactid ? DBID_to_name ($initialqacontactid) : ''; @@ -663,8 +660,7 @@ if ($action eq 'edit') { print "

Edit component ...
Component of product:"; SendSQL("SELECT count(*) FROM bugs - WHERE product=" . SqlQuote($product) . - " and component=" . SqlQuote($component)); + WHERE component_id=$component_id"); my $bugs = ''; $bugs = FetchOneColumn() if MoreSQLData(); print $bugs || 'none'; @@ -707,13 +703,12 @@ if ($action eq 'update') { my $initialqacontact = trim($::FORM{initialqacontact} || ''); my $initialqacontactold = trim($::FORM{initialqacontactold} || ''); - CheckComponent($product,$componentold); - # Note that the order of this tests is important. If you change # them, be sure to test for WHERE='$component' or WHERE='$componentold' - SendSQL("LOCK TABLES bugs WRITE, - components WRITE, profiles READ"); + SendSQL("LOCK TABLES components WRITE, products READ, profiles READ"); + CheckComponent($product,$componentold); + my $component_id = get_component_id($product,$componentold); if ($description ne $descriptionold) { unless ($description) { @@ -724,8 +719,7 @@ if ($action eq 'update') { } SendSQL("UPDATE components SET description=" . SqlQuote($description) . " - WHERE program=" . SqlQuote($product) . " - AND value=" . SqlQuote($componentold)); + WHERE id=$component_id"); print "Updated description.
\n"; } @@ -748,8 +742,7 @@ if ($action eq 'update') { SendSQL("UPDATE components SET initialowner=" . SqlQuote($initialownerid) . " - WHERE program=" . SqlQuote($product) . " - AND value=" . SqlQuote($componentold)); + WHERE id = $component_id"); print "Updated initial owner.
\n"; } @@ -764,8 +757,7 @@ if ($action eq 'update') { SendSQL("UPDATE components SET initialqacontact=" . SqlQuote($initialqacontactid) . " - WHERE program=" . SqlQuote($product) . " - AND value=" . SqlQuote($componentold)); + WHERE id = $component_id"); print "Updated initial QA contact.
\n"; } @@ -784,15 +776,8 @@ if ($action eq 'update') { exit; } - SendSQL("UPDATE bugs - SET component=" . SqlQuote($component) . ", - delta_ts = delta_ts - WHERE component=" . SqlQuote($componentold) . " - AND product=" . SqlQuote($product)); - SendSQL("UPDATE components - SET value=" . SqlQuote($component) . " - WHERE value=" . SqlQuote($componentold) . " - AND program=" . SqlQuote($product)); + SendSQL("UPDATE components SET name=" . SqlQuote($component) . + "WHERE id=$component_id"); unlink "data/versioncache"; print "Updated component name.
\n"; diff --git a/mozilla/webtools/bugzilla/editgroups.cgi b/mozilla/webtools/bugzilla/editgroups.cgi index c502ddce82d..ea649a4d287 100755 --- a/mozilla/webtools/bugzilla/editgroups.cgi +++ b/mozilla/webtools/bugzilla/editgroups.cgi @@ -449,7 +449,7 @@ this box. It is strongly suggested that you review the bugs in this group before checking the box.

"; } - SendSQL("SELECT product FROM products WHERE product=" . SqlQuote($name)); + SendSQL("SELECT name FROM products WHERE name=" . SqlQuote($name)); if (MoreSQLData()) { $cantdelete = 1; print " @@ -508,7 +508,7 @@ if ($action eq 'delete') { $cantdelete = 1; } } - SendSQL("SELECT product FROM products WHERE product=" . SqlQuote($name)); + SendSQL("SELECT name FROM products WHERE name=" . SqlQuote($name)); if (FetchOneColumn()) { if (!defined $::FORM{'unbind'}) { $cantdelete = 1; diff --git a/mozilla/webtools/bugzilla/editmilestones.cgi b/mozilla/webtools/bugzilla/editmilestones.cgi index fccf7253362..72c7181cf2e 100755 --- a/mozilla/webtools/bugzilla/editmilestones.cgi +++ b/mozilla/webtools/bugzilla/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(); } @@ -164,6 +164,7 @@ unless (UserInGroup("editcomponents")) { # often used variables # my $product = trim($::FORM{product} || ''); +my $product_id = get_product_id($product); my $milestone = trim($::FORM{milestone} || ''); my $sortkey = trim($::FORM{sortkey} || '0'); my $action = trim($::FORM{action} || ''); @@ -183,10 +184,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"; @@ -219,7 +220,7 @@ unless ($action) { 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"; @@ -305,10 +306,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"; @@ -331,15 +331,15 @@ if ($action eq 'del') { PutHeader("Delete milestone of $product"); CheckMilestone($product, $milestone); - 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"; @@ -422,7 +422,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 +439,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"); @@ -467,8 +467,8 @@ if ($action eq 'edit') { PutHeader("Edit milestone of $product"); CheckMilestone($product,$milestone); - 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"; @@ -535,14 +535,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"; diff --git a/mozilla/webtools/bugzilla/editproducts.cgi b/mozilla/webtools/bugzilla/editproducts.cgi index 732d95f7873..6876075426f 100755 --- a/mozilla/webtools/bugzilla/editproducts.cgi +++ b/mozilla/webtools/bugzilla/editproducts.cgi @@ -51,9 +51,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(); } @@ -199,12 +199,11 @@ my $localtrailer = "edit more products"; unless ($action) { PutHeader("Select product"); - SendSQL("SELECT products.product,description,disallownew, + SendSQL("SELECT products.name,description,disallownew, votesperuser,maxvotesperbug,votestoconfirm,COUNT(bug_id) - FROM products LEFT JOIN bugs - ON products.product=bugs.product - GROUP BY products.product - ORDER BY products.product"); + FROM products LEFT JOIN bugs ON products.id = bugs.product_id + GROUP BY products.name + ORDER BY products.name"); print "

\n"; print " \n"; print " \n"; @@ -322,7 +321,7 @@ if ($action eq 'new') { # Add the new product. SendSQL("INSERT INTO products ( " . - "product, description, milestoneurl, disallownew, votesperuser, " . + "name, description, milestoneurl, disallownew, votesperuser, " . "maxvotesperbug, votestoconfirm, defaultmilestone" . " ) VALUES ( " . SqlQuote($product) . "," . @@ -331,14 +330,16 @@ if ($action eq 'new') { $disallownew . "," . "$votesperuser, $maxvotesperbug, $votestoconfirm, " . SqlQuote($defaultmilestone) . ")"); + SendSQL("SELECT LAST_INSERT_ID()"); + my $product_id = FetchOneColumn(); SendSQL("INSERT INTO versions ( " . - "value, program" . + "value, product_id" . " ) VALUES ( " . SqlQuote($version) . "," . - SqlQuote($product) . ")" ); + $product_id . ")" ); - SendSQL("INSERT INTO milestones (product, value) VALUES (" . - SqlQuote($product) . ", " . SqlQuote($defaultmilestone) . ")"); + SendSQL("INSERT INTO milestones (product_id, value) VALUES (" . + $product_id . ", " . SqlQuote($defaultmilestone) . ")"); # If we're using bug groups, then we need to create a group for this # product as well. -JMR, 2/16/00 @@ -374,10 +375,10 @@ if ($action eq 'del') { CheckProduct($product); # display some data about the product - SendSQL("SELECT description, milestoneurl, disallownew + SendSQL("SELECT product_id, description, milestoneurl, disallownew FROM products - WHERE product=" . SqlQuote($product)); - my ($description, $milestoneurl, $disallownew) = FetchSQLData(); + WHERE name=" . SqlQuote($product)); + my ($product_id, $description, $milestoneurl, $disallownew) = FetchSQLData(); my $milestonelink = $milestoneurl ? "$milestoneurl" : "missing"; $description ||= "description missing"; @@ -410,9 +411,9 @@ if ($action eq 'del') { print "\n"; print " \n"; print "
Edit product ...Description
Components:"; - SendSQL("SELECT value,description + SendSQL("SELECT name,description FROM components - WHERE program=" . SqlQuote($product)); + WHERE product_id=$product_id"); if (MoreSQLData()) { print ""; while ( MoreSQLData() ) { @@ -431,7 +432,7 @@ if ($action eq 'del') { print " \n\n"; print " \n"; print " \n"; print " \n"; print "
"; SendSQL("SELECT value FROM versions - WHERE program=" . SqlQuote($product) . " + WHERE product_id=$product_id ORDER BY value"); if (MoreSQLData()) { my $br = 0; @@ -454,7 +455,7 @@ if ($action eq 'del') { print " "; SendSQL("SELECT value FROM milestones - WHERE product=" . SqlQuote($product) . " + WHERE product_id=$product_id ORDER BY sortkey,value"); if(MoreSQLData()) { my $br = 0; @@ -472,10 +473,10 @@ if ($action eq 'del') { print "
Bugs:"; - SendSQL("SELECT count(bug_id),product + SendSQL("SELECT count(bug_id),product_id FROM bugs - GROUP BY product - HAVING product=" . SqlQuote($product)); + GROUP BY product_id + HAVING product_id=$product_id"); my $bugs = FetchOneColumn(); print $bugs || 'none'; @@ -520,6 +521,7 @@ one."; if ($action eq 'delete') { PutHeader("Deleting product"); CheckProduct($product); + my $product_id = get_product_id($product); # lock the tables before we start to change everything: @@ -541,7 +543,7 @@ if ($action eq 'delete') { if (Param("allowbugdeletion")) { SendSQL("SELECT bug_id FROM bugs - WHERE product=" . SqlQuote($product)); + WHERE product_id=$product_id"); while (MoreSQLData()) { my $bugid = FetchOneColumn(); @@ -557,25 +559,25 @@ if ($action eq 'delete') { # Deleting the rest is easier: SendSQL("DELETE FROM bugs - WHERE product=" . SqlQuote($product)); + WHERE product_id=$product_id"); print "Bugs deleted.
\n"; } SendSQL("DELETE FROM components - WHERE program=" . SqlQuote($product)); + WHERE product_id=$product_id"); print "Components deleted.
\n"; SendSQL("DELETE FROM versions - WHERE program=" . SqlQuote($product)); + WHERE product_id=$product_id"); print "Versions deleted.

\n"; # deleting associated target milestones - matthew@zeroknowledge.com SendSQL("DELETE FROM milestones - WHERE product=" . SqlQuote($product)); + WHERE product_id=$product_id"); print "Milestones deleted.
\n"; SendSQL("DELETE FROM products - WHERE product=" . SqlQuote($product)); + WHERE product_id=$product_id"); print "Product '$product' deleted.
\n"; @@ -599,11 +601,11 @@ if ($action eq 'edit') { CheckProduct($product); # get data of product - SendSQL("SELECT description,milestoneurl,disallownew, + SendSQL("SELECT id,description,milestoneurl,disallownew, votesperuser,maxvotesperbug,votestoconfirm,defaultmilestone FROM products - WHERE product=" . SqlQuote($product)); - my ($description, $milestoneurl, $disallownew, + WHERE name=" . SqlQuote($product)); + my ($product_id,$description, $milestoneurl, $disallownew, $votesperuser, $maxvotesperbug, $votestoconfirm, $defaultmilestone) = FetchSQLData(); @@ -617,9 +619,9 @@ if ($action eq 'edit') { print "

Edit components:"; - SendSQL("SELECT value,description + SendSQL("SELECT name,description FROM components - WHERE program=" . SqlQuote($product)); + WHERE product_id=$product_id"); if (MoreSQLData()) { print ""; while ( MoreSQLData() ) { @@ -639,7 +641,7 @@ if ($action eq 'edit') { print " \n\n"; print " \n"; print "
"; SendSQL("SELECT value FROM versions - WHERE program=" . SqlQuote($product) . " + WHERE product_id=$product_id ORDER BY value"); if (MoreSQLData()) { my $br = 0; @@ -662,7 +664,7 @@ if ($action eq 'edit') { print " "; SendSQL("SELECT value FROM milestones - WHERE product=" . SqlQuote($product) . " + WHERE product_id=$product_id ORDER BY sortkey,value"); if(MoreSQLData()) { my $br = 0; @@ -680,10 +682,10 @@ if ($action eq 'edit') { print "
Bugs:"; - SendSQL("SELECT count(bug_id),product + SendSQL("SELECT count(bug_id),product_id FROM bugs - GROUP BY product - HAVING product=" . SqlQuote($product)); + GROUP BY product_id + HAVING product_id=$product_id"); my $bugs = ''; $bugs = FetchOneColumn() if MoreSQLData(); print $bugs || 'none'; @@ -741,6 +743,7 @@ if ($action eq 'update') { my $checkvotes = 0; CheckProduct($productold); + my $product_id = get_product_id($productold); if ($maxvotesperbug !~ /^\d+$/ || $maxvotesperbug <= 0) { print "Sorry, the max votes per bug must be a positive integer."; @@ -748,22 +751,20 @@ if ($action eq 'update') { exit; } - # Note that the order of this tests is important. If you change - # them, be sure to test for WHERE='$product' or WHERE='$productold' + # Note that we got the $product_id using $productold above so it will + # remain static even after we rename the product in the database. - SendSQL("LOCK TABLES bugs WRITE, - components WRITE, - products WRITE, - versions WRITE, + SendSQL("LOCK TABLES products WRITE, + versions READ, groups WRITE, profiles WRITE, - milestones WRITE"); + milestones READ"); if ($disallownew ne $disallownewold) { $disallownew ||= 0; SendSQL("UPDATE products SET disallownew=$disallownew - WHERE product=" . SqlQuote($productold)); + WHERE id=$product_id"); print "Updated bug submit status.
\n"; } @@ -776,14 +777,14 @@ if ($action eq 'update') { } SendSQL("UPDATE products SET description=" . SqlQuote($description) . " - WHERE product=" . SqlQuote($productold)); + WHERE id=$product_id"); print "Updated description.
\n"; } if (Param('usetargetmilestone') && $milestoneurl ne $milestoneurlold) { SendSQL("UPDATE products SET milestoneurl=" . SqlQuote($milestoneurl) . " - WHERE product=" . SqlQuote($productold)); + WHERE id=$product_id"); print "Updated mile stone URL.
\n"; } @@ -791,7 +792,7 @@ if ($action eq 'update') { if ($votesperuser ne $votesperuserold) { SendSQL("UPDATE products SET votesperuser=$votesperuser - WHERE product=" . SqlQuote($productold)); + WHERE id=$product_id"); print "Updated votes per user.
\n"; $checkvotes = 1; } @@ -800,7 +801,7 @@ if ($action eq 'update') { if ($maxvotesperbug ne $maxvotesperbugold) { SendSQL("UPDATE products SET maxvotesperbug=$maxvotesperbug - WHERE product=" . SqlQuote($productold)); + WHERE id=$product_id"); print "Updated max votes per bug.
\n"; $checkvotes = 1; } @@ -809,7 +810,7 @@ if ($action eq 'update') { if ($votestoconfirm ne $votestoconfirmold) { SendSQL("UPDATE products SET votestoconfirm=$votestoconfirm - WHERE product=" . SqlQuote($productold)); + WHERE id=$product_id"); print "Updated votes to confirm.
\n"; $checkvotes = 1; } @@ -818,7 +819,7 @@ if ($action eq 'update') { if ($defaultmilestone ne $defaultmilestoneold) { SendSQL("SELECT value FROM milestones " . "WHERE value = " . SqlQuote($defaultmilestone) . - " AND product = " . SqlQuote($productold)); + " AND product_id = $product_id"); if (!FetchOneColumn()) { print "Sorry, the milestone $defaultmilestone must be defined first."; SendSQL("UNLOCK TABLES"); @@ -827,7 +828,7 @@ if ($action eq 'update') { } SendSQL("UPDATE products " . "SET defaultmilestone = " . SqlQuote($defaultmilestone) . - "WHERE product=" . SqlQuote($productold)); + "WHERE id=$product_id"); print "Updated default milestone.
\n"; } @@ -848,11 +849,7 @@ if ($action eq 'update') { exit; } - SendSQL("UPDATE bugs SET product=$qp, delta_ts=delta_ts WHERE product=$qpold"); - SendSQL("UPDATE components SET program=$qp WHERE program=$qpold"); - SendSQL("UPDATE products SET product=$qp WHERE product=$qpold"); - SendSQL("UPDATE versions SET program=$qp WHERE program=$qpold"); - SendSQL("UPDATE milestones SET product=$qp WHERE product=$qpold"); + SendSQL("UPDATE products SET name=$qp WHERE id=$product_id"); # Need to do an update to groups as well. If there is a corresponding # bug group, whether usebuggroups is currently set or not, we want to # update it so it will match in the future. If there is no group, this @@ -873,7 +870,7 @@ if ($action eq 'update') { SendSQL("SELECT votes.who, votes.bug_id " . "FROM votes, bugs " . "WHERE bugs.bug_id = votes.bug_id " . - " AND bugs.product = $qp " . + " AND bugs.product_id = $product_id " . " AND votes.count > $maxvotesperbug"); my @list; while (MoreSQLData()) { @@ -889,7 +886,7 @@ if ($action eq 'update') { } SendSQL("SELECT votes.who, votes.count FROM votes, bugs " . "WHERE bugs.bug_id = votes.bug_id " . - " AND bugs.product = $qp"); + " AND bugs.product_id = $product_id"); my %counts; while (MoreSQLData()) { my ($who, $count) = (FetchSQLData()); @@ -903,7 +900,7 @@ if ($action eq 'update') { if ($counts{$who} > $votesperuser) { SendSQL("SELECT votes.bug_id FROM votes, bugs " . "WHERE bugs.bug_id = votes.bug_id " . - " AND bugs.product = $qp " . + " AND bugs.product_id = $product_id " . " AND votes.who = $who"); while (MoreSQLData()) { my $id = FetchSQLData(); @@ -915,7 +912,7 @@ if ($action eq 'update') { } } SendSQL("SELECT bug_id FROM bugs " . - "WHERE product = $qp " . + "WHERE product_id = $product_id " . " AND bug_status = '$::unconfirmedstate' " . " AND votes >= $votestoconfirm"); my @list; diff --git a/mozilla/webtools/bugzilla/editusers.cgi b/mozilla/webtools/bugzilla/editusers.cgi index 2224289c988..f08d76c1d2f 100755 --- a/mozilla/webtools/bugzilla/editusers.cgi +++ b/mozilla/webtools/bugzilla/editusers.cgi @@ -551,9 +551,10 @@ if ($action eq 'del') { # Check if the user is an initialowner my $nodelete = ''; - SendSQL("SELECT program, value - FROM components - WHERE initialowner=" . DBname_to_id($user)); + SendSQL("SELECT products.name, components.name " . + "FROM products, components " . + "WHERE products.id = components.product_id " . + " AND initialowner=" . DBname_to_id($user)); $found = 0; while (MoreSQLData()) { if ($found) { @@ -575,9 +576,10 @@ if ($action eq 'del') { # Check if the user is an initialqacontact - SendSQL("SELECT program, value - FROM components - WHERE initialqacontact=" . DBname_to_id($user)); + SendSQL("SELECT products.name, components.name " . + "FROM products, components " . + "WHERE products.id = components.id " . + " AND initialqacontact=" . DBname_to_id($user)); $found = 0; while (MoreSQLData()) { if ($found) { diff --git a/mozilla/webtools/bugzilla/editversions.cgi b/mozilla/webtools/bugzilla/editversions.cgi index 950d597a798..2097b624085 100755 --- a/mozilla/webtools/bugzilla/editversions.cgi +++ b/mozilla/webtools/bugzilla/editversions.cgi @@ -46,9 +46,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(); } @@ -75,9 +75,9 @@ sub TestVersion ($$) my ($prod,$ver) = @_; # does the product exist? - SendSQL("SELECT program,value - FROM versions - WHERE program=" . SqlQuote($prod) . " and value=" . SqlQuote($ver)); + SendSQL("SELECT products.name,value + FROM versions, products + WHERE versions.product_id=products.id AND products.name=" . SqlQuote($prod) . " and value=" . SqlQuote($ver)); return FetchOneColumn(); } @@ -191,10 +191,10 @@ if ($version) { 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"; @@ -217,7 +217,7 @@ unless ($product) { exit; } - +my $product_id = get_product_id($product); # # action='' -> Show nice list of versions @@ -227,23 +227,9 @@ unless ($action) { PutHeader("Select version of $product"); CheckProduct($product); -=for me - - # Das geht nicht wie vermutet. Ich bekomme nicht alle Versionen - # angezeigt! Schade. Ich würde gerne sehen, wieviel Bugs pro - # Version angegeben sind ... - - SendSQL("SELECT value,program,COUNT(bug_id) - FROM versions LEFT JOIN bugs - ON program=product AND value=version - WHERE program=" . SqlQuote($product) . " - GROUP BY value"); - -=cut - - SendSQL("SELECT value,program - FROM versions - WHERE program=" . SqlQuote($product) . " + SendSQL("SELECT value + FROM versions + WHERE product_id=$product_id ORDER BY value"); print "
Edit versions of ...Description
\n"; @@ -252,8 +238,7 @@ unless ($action) { print " \n"; print ""; while ( MoreSQLData() ) { - my ($version,$dummy,$bugs) = FetchSQLData(); - $bugs ||= 'none'; + my $version = FetchOneColumn(); print "\n"; print " \n"; #print " \n"; @@ -327,10 +312,9 @@ if ($action eq 'new') { # Add the new version SendSQL("INSERT INTO versions ( " . - "value, program" . + "value, product_id" . " ) VALUES ( " . - SqlQuote($version) . "," . - SqlQuote($product) . ")"); + SqlQuote($version) . ", $product_id)"); # Make versioncache flush unlink "data/versioncache"; @@ -353,11 +337,10 @@ if ($action eq 'del') { PutHeader("Delete version of $product"); CheckVersion($product, $version); - SendSQL("SELECT count(bug_id),product,version + SendSQL("SELECT count(bug_id) FROM bugs - GROUP BY product,version - HAVING product=" . SqlQuote($product) . " - AND version=" . SqlQuote($version)); + WHERE product_id = $product_id + AND version = " . SqlQuote($version)); my $bugs = FetchOneColumn(); print "
Action
$version$bugs
\n"; @@ -433,7 +416,7 @@ if ($action eq 'delete') { SendSQL("SELECT bug_id FROM bugs - WHERE product=" . SqlQuote($product) . " + WHERE product_id=$product_id AND version=" . SqlQuote($version)); while (MoreSQLData()) { my $bugid = FetchOneColumn(); @@ -450,13 +433,13 @@ if ($action eq 'delete') { # Deleting the rest is easier: SendSQL("DELETE FROM bugs - WHERE product=" . SqlQuote($product) . " + WHERE product_id = $product_id AND version=" . SqlQuote($version)); print "Bugs deleted.
\n"; } SendSQL("DELETE FROM versions - WHERE program=" . SqlQuote($product) . " + WHERE product_id = $product_id AND value=" . SqlQuote($version)); print "Version deleted.

\n"; SendSQL("UNLOCK TABLES"); @@ -515,7 +498,8 @@ if ($action eq 'update') { # them, be sure to test for WHERE='$version' or WHERE='$versionold' SendSQL("LOCK TABLES bugs WRITE, - versions WRITE"); + versions WRITE, + products READ"); if ($version ne $versionold) { unless ($version) { @@ -534,10 +518,10 @@ if ($action eq 'update') { SET version=" . SqlQuote($version) . ", delta_ts = delta_ts WHERE version=" . SqlQuote($versionold) . " - AND product=" . SqlQuote($product)); + AND product_id = $product_id"); SendSQL("UPDATE versions SET value=" . SqlQuote($version) . " - WHERE program=" . SqlQuote($product) . " + WHERE product_id = $product_id AND value=" . SqlQuote($versionold)); unlink "data/versioncache"; print "Updated version.
\n"; diff --git a/mozilla/webtools/bugzilla/enter_bug.cgi b/mozilla/webtools/bugzilla/enter_bug.cgi index a07a04b039e..c630a1a1939 100755 --- a/mozilla/webtools/bugzilla/enter_bug.cgi +++ b/mozilla/webtools/bugzilla/enter_bug.cgi @@ -239,7 +239,9 @@ if (lsearch(\@::enterable_products, $product) == -1) { DisplayError("'" . html_quote($product) . "' is not a valid product."); exit; } - + +my $product_id = get_product_id($product); + if (0 == @{$::components{$product}}) { my $error = "Sorry; there needs to be at least one component for this " . "product in order to create a new bug. "; @@ -261,8 +263,8 @@ elsif (1 == @{$::components{$product}}) { } my @components; -SendSQL("SELECT value, description FROM components " . - "WHERE program = " . SqlQuote($product) . " ORDER BY value"); +SendSQL("SELECT name, description FROM components " . + "WHERE product_id = $product_id ORDER BY name"); while (MoreSQLData()) { my ($name, $description) = FetchSQLData(); @@ -315,7 +317,7 @@ if (exists $::COOKIE{"VERSION-$product"} && my @status = "NEW"; if (UserInGroup("editbugs") || UserInGroup("canconfirm")) { - SendSQL("SELECT votestoconfirm FROM products WHERE product = " . + SendSQL("SELECT votestoconfirm FROM products WHERE name = " . SqlQuote($product)); push(@status, $unconfirmedstate) if (FetchOneColumn()); } diff --git a/mozilla/webtools/bugzilla/globals.pl b/mozilla/webtools/bugzilla/globals.pl index 9724369012b..1c7637a070b 100644 --- a/mozilla/webtools/bugzilla/globals.pl +++ b/mozilla/webtools/bugzilla/globals.pl @@ -433,7 +433,10 @@ sub GenerateArrayCode { sub GenerateVersionTable { - SendSQL("select value, program from versions order by value"); + SendSQL("SELECT versions.value, products.name " . + "FROM versions, products " . + "WHERE products.id = versions.product_id " . + "ORDER BY versions.value"); my @line; my %varray; my %carray; @@ -445,7 +448,10 @@ sub GenerateVersionTable { push @{$::versions{$p1}}, $v; $varray{$v} = 1; } - SendSQL("select value, program from components order by value"); + SendSQL("SELECT components.name, products.name " . + "FROM components, products " . + "WHERE products.id = components.product_id " . + "ORDER BY components.name"); while (@line = FetchSQLData()) { my ($c,$p) = (@line); if (!defined $::components{$p}) { @@ -463,7 +469,7 @@ sub GenerateVersionTable { # about them anyway. my $mpart = $dotargetmilestone ? ", milestoneurl" : ""; - SendSQL("select product, description, votesperuser, disallownew$mpart from products ORDER BY product"); + SendSQL("select name, description, votesperuser, disallownew$mpart from products ORDER BY name"); while (@line = FetchSQLData()) { my ($p, $d, $votesperuser, $dis, $u) = (@line); $::proddesc{$p} = $d; @@ -545,7 +551,10 @@ sub GenerateVersionTable { if ($dotargetmilestone) { # reading target milestones in from the database - matthew@zeroknowledge.com - SendSQL("SELECT value, product FROM milestones ORDER BY sortkey, value"); + SendSQL("SELECT milestones.value, products.name " . + "FROM milestones, products " . + "WHERE products.id = milestones.product_id " . + "ORDER BY milestones.sortkey, milestones.value"); my @line; my %tmarray; @::legal_target_milestone = (); @@ -922,6 +931,50 @@ sub DBNameToIdAndCheck { registered for a Bugzilla account."); } +sub get_product_id { + my ($prod) = @_; + PushGlobalSQLState(); + SendSQL("SELECT id FROM products WHERE name = " . SqlQuote($prod)); + my ($prod_id) = FetchSQLData(); + PopGlobalSQLState(); + detaint_natural($prod_id) || die "get_product_id() returned a non-integer"; + return $prod_id; +} + +sub get_product_name { + my ($prod_id) = @_; + detaint_natural($prod_id) || die "get_product_name() was called with a non-integer paramater"; + PushGlobalSQLState(); + SendSQL("SELECT name FROM products WHERE id = $prod_id"); + my ($prod) = FetchSQLData(); + PopGlobalSQLState(); + return $prod; +} + +sub get_component_id { + my ($prod, $comp) = @_; + PushGlobalSQLState(); + SendSQL("SELECT components.id " . + "FROM components, products " . + "WHERE products.id = components.product_id " . + " AND products.name = " . SqlQuote($prod) . + " AND components.name = " . SqlQuote($comp)); + my ($comp_id) = FetchSQLData(); + PopGlobalSQLState(); + detaint_natural($comp_id) || die "get_component_id() returned a non-integer"; + return $comp_id; +} + +sub get_component_name { + my ($comp_id) = @_; + detaint_natural($comp_id) || die "get_component_name() was called with a non-integer paramater"; + PushGlobalSQLState(); + SendSQL("SELECT name FROM components WHERE id = $comp_id"); + my ($comp) = FetchSQLData(); + PopGlobalSQLState(); + return $comp; +} + # Use trick_taint() when you know that there is no way that the data # in a scalar can be tainted, but taint mode still bails on it. # WARNING!! Using this routine on data that really could be tainted @@ -1421,7 +1474,7 @@ sub RemoveVotes { "FROM profiles " . "LEFT JOIN votes ON profiles.userid = votes.who " . "LEFT JOIN bugs USING(bug_id) " . - "LEFT JOIN products USING(product)" . + "LEFT JOIN products ON products.id = bugs.product_id " . "WHERE votes.bug_id = $id " . $whopart); my @list; diff --git a/mozilla/webtools/bugzilla/importxml.pl b/mozilla/webtools/bugzilla/importxml.pl index 964d29a6f04..cffeca68c7e 100755 --- a/mozilla/webtools/bugzilla/importxml.pl +++ b/mozilla/webtools/bugzilla/importxml.pl @@ -570,9 +570,10 @@ for (my $k=1 ; $k <= $bugqty ; $k++) { push (@values, SqlQuote($qa_contact)); push (@query, "qa_contact"); } else { - SendSQL("select initialqacontact from components where program=" . - SqlQuote($product[0]) . - " and value=" . SqlQuote($component[0]) ); + SendSQL("SELECT initialqacontact FROM components, products " + "WHERE components.product_id = products.id" . + " AND products.name = " . SqlQuote($product[0]) . + " AND components.name = " . SqlQuote($component[0]) ); $qa_contact = FetchOneColumn(); push (@values, SqlQuote(DBname_to_id($qa_contact)) ); push (@query, "qa_contact"); diff --git a/mozilla/webtools/bugzilla/long_list.cgi b/mozilla/webtools/bugzilla/long_list.cgi index f29ed7c2ea6..2b3b0c465ee 100755 --- a/mozilla/webtools/bugzilla/long_list.cgi +++ b/mozilla/webtools/bugzilla/long_list.cgi @@ -41,7 +41,7 @@ GetVersionTable(); my $generic_query = " SELECT bugs.bug_id, - bugs.product, + products.name, bugs.version, bugs.rep_platform, bugs.op_sys, @@ -49,7 +49,7 @@ my $generic_query = " bugs.resolution, bugs.priority, bugs.bug_severity, - bugs.component, + components.name, assign.login_name, report.login_name, bugs.bug_file_loc, @@ -58,8 +58,9 @@ my $generic_query = " bugs.qa_contact, bugs.status_whiteboard, bugs.keywords - FROM bugs,profiles assign,profiles report - WHERE assign.userid = bugs.assigned_to AND report.userid = bugs.reporter"; + FROM bugs,profiles assign,profiles report, products, components + WHERE assign.userid = bugs.assigned_to AND report.userid = bugs.reporter + AND bugs.product_id=products.id AND bugs.component_id=components.id"; my $buglist = $::FORM{'buglist'} || $::FORM{'bug_id'} || diff --git a/mozilla/webtools/bugzilla/post_bug.cgi b/mozilla/webtools/bugzilla/post_bug.cgi index 18eaad40c3e..f74658253e2 100755 --- a/mozilla/webtools/bugzilla/post_bug.cgi +++ b/mozilla/webtools/bugzilla/post_bug.cgi @@ -69,6 +69,11 @@ $template->process("$template_name.txt.tmpl", $vars, \$comment) ValidateComment($comment); my $product = $::FORM{'product'}; +my $product_id = get_product_id($product); +if (!$product_id) { + ThrowUserError("Sorry, the product " . html_quote($product) . + " does not exist"); +} # Set cookies my $cookiepath = Param("cookiepath"); @@ -99,10 +104,11 @@ if(Param("usebuggroupsentry") && GroupExists($product)) { } } -if (!$::FORM{'component'}) { +my $component_id = get_component_id($product, $::FORM{component}); +if (!$component_id) { DisplayError("You must choose a component that corresponds to this bug. If necessary, just guess."); - exit; + exit; } if (!defined $::FORM{'short_desc'} || trim($::FORM{'short_desc'}) eq "") { @@ -120,20 +126,20 @@ my $sql_component = SqlQuote($::FORM{'component'}); # Default assignee is the component owner. if ($::FORM{'assigned_to'} eq "") { SendSQL("SELECT initialowner FROM components " . - "WHERE program=$sql_product AND value=$sql_component"); + "WHERE id = $component_id"); $::FORM{'assigned_to'} = FetchOneColumn(); } else { $::FORM{'assigned_to'} = DBNameToIdAndCheck(trim($::FORM{'assigned_to'})); } -my @bug_fields = ("product", "version", "rep_platform", +my @bug_fields = ("version", "rep_platform", "bug_severity", "priority", "op_sys", "assigned_to", - "bug_status", "bug_file_loc", "short_desc", "component", + "bug_status", "bug_file_loc", "short_desc", "target_milestone"); if (Param("useqacontact")) { SendSQL("SELECT initialqacontact FROM components " . - "WHERE program=$sql_product AND value=$sql_component"); + "WHERE id = $component_id"); my $qa_contact = FetchOneColumn(); if (defined $qa_contact && $qa_contact != 0) { $::FORM{'qa_contact'} = $qa_contact; @@ -154,14 +160,14 @@ if (exists $::FORM{'bug_status'}) { if (!exists $::FORM{'bug_status'}) { $::FORM{'bug_status'} = $::unconfirmedstate; - SendSQL("SELECT votestoconfirm FROM products WHERE product=$sql_product"); + SendSQL("SELECT votestoconfirm FROM products WHERE id = $product_id"); if (!FetchOneColumn()) { $::FORM{'bug_status'} = "NEW"; } } if (!exists $::FORM{'target_milestone'}) { - SendSQL("SELECT defaultmilestone FROM products WHERE product=$sql_product"); + SendSQL("SELECT defaultmilestone FROM products WHERE name=$sql_product"); $::FORM{'target_milestone'} = FetchOneColumn(); } @@ -199,6 +205,11 @@ if (exists $::FORM{'bug_status'} $::FORM{'everconfirmed'} = 1; } +$::FORM{'product_id'} = $product_id; +push(@used_fields, "product_id"); +$::FORM{component_id} = $component_id; +push(@used_fields, "component_id"); + my %ccids; my @cc; diff --git a/mozilla/webtools/bugzilla/process_bug.cgi b/mozilla/webtools/bugzilla/process_bug.cgi index e8e871c4c85..8b339491ffd 100755 --- a/mozilla/webtools/bugzilla/process_bug.cgi +++ b/mozilla/webtools/bugzilla/process_bug.cgi @@ -173,7 +173,8 @@ sub CheckonComment( $ ) { # and make the user verify the version, component, target milestone, # and bug groups if so. if ( $::FORM{'id'} ) { - SendSQL("SELECT product FROM bugs WHERE bug_id = $::FORM{'id'}"); + SendSQL("SELECT name FROM products, bugs " . + "WHERE products.id = bugs.product_id AND bug_id = $::FORM{'id'}"); $::oldproduct = FetchSQLData(); } if ((($::FORM{'id'} && $::FORM{'product'} ne $::oldproduct) @@ -495,8 +496,8 @@ while (my ($b, $isactive) = FetchSQLData()) { } foreach my $field ("rep_platform", "priority", "bug_severity", - "summary", "component", "bug_file_loc", "short_desc", - "product", "version", "op_sys", + "summary", "bug_file_loc", "short_desc", + "version", "op_sys", "target_milestone", "status_whiteboard") { if (defined $::FORM{$field}) { if ($::FORM{$field} ne $::dontchange) { @@ -506,6 +507,41 @@ foreach my $field ("rep_platform", "priority", "bug_severity", } } +my $prod_id; # Remember, can't use this for mass changes +if ($::FORM{'product'} ne $::dontchange) { + $prod_id = get_product_id($::FORM{'product'}); + if (! $prod_id) { + DisplayError("The " . html_quote($::FORM{'product'}) . + " product doesn't exist."); + exit; + } + DoComma(); + $::query .= "product_id = $prod_id"; +} else { + SendSQL("SELECT DISTINCT product_id FROM bugs WHERE bug_id IN (" . + join(',', @idlist) . ") LIMIT 2"); + $prod_id = FetchOneColumn(); + $prod_id = undef if (FetchOneColumn()); +} + +my $comp_id; # Remember, can't use this for mass changes +if ($::FORM{'component'} ne $::dontchange) { + if (!defined $prod_id) { + ThrowUserError("You cannot change the component from a list of bugs " . + "covering more than one product"); + } + $comp_id = get_component_id(get_product_name($prod_id), + $::FORM{'component'}); + if (! $comp_id) { + DisplayError("The " . html_quote($::FORM{'component'}) . + " component doesn't exist in the " . + html_quote($::FORM{'product'}) . " product"); + exit; + } + DoComma(); + $::query .= "component_id = $comp_id"; +} + # If this installation uses bug aliases, and the user is changing the alias, # add this change to the query. if (Param("usebugaliases") && defined($::FORM{'alias'})) { @@ -700,17 +736,15 @@ SWITCH: for ($::FORM{'knob'}) { DoConfirm(); } ChangeStatus('NEW'); - SendSQL("select initialowner from components where program=" . - SqlQuote($::FORM{'product'}) . " and value=" . - SqlQuote($::FORM{'component'})); + SendSQL("SELECT initialowner FROM components " . + "WHERE components.id = $comp_id"); my $newid = FetchOneColumn(); my $newname = DBID_to_name($newid); DoComma(); $::query .= "assigned_to = $newid"; if (Param("useqacontact")) { - SendSQL("select initialqacontact from components where program=" . - SqlQuote($::FORM{'product'}) . - " and value=" . SqlQuote($::FORM{'component'})); + SendSQL("SELECT initialqacontact FROM components " . + "WHERE components.id = $comp_id"); my $qacontact = FetchOneColumn(); if (defined $qacontact && $qacontact != 0) { DoComma(); @@ -915,10 +949,11 @@ foreach my $id (@idlist) { SendSQL("LOCK TABLES bugs $write, bugs_activity $write, cc $write, " . "cc AS selectVisible_cc $write, " . "profiles $write, dependencies $write, votes $write, " . + "products READ, components READ, " . "keywords $write, longdescs $write, fielddefs $write, " . "bug_group_map $write, " . "member_group_map READ, " . - "keyworddefs READ, groups READ, attachments READ, products READ"); + "keyworddefs READ, groups READ, attachments READ"); my @oldvalues = SnapShotBug($id); my %oldhash; my $i = 0; @@ -1283,6 +1318,17 @@ foreach my $id (@idlist) { } if ($old ne $new) { + # Products and components are now stored in the DB using ID's + # We need to translate this to English before logging it + if ($col eq 'product_id') { + $old = get_product_name($old); + $new = get_product_name($new); + } + if ($col eq 'component_id') { + $old = get_component_name($old); + $new = get_component_name($new); + } + # save off the old value for passing to processmail so the old # owner can be notified # diff --git a/mozilla/webtools/bugzilla/processmail b/mozilla/webtools/bugzilla/processmail index 65af6df84be..d5f28d0e97c 100755 --- a/mozilla/webtools/bugzilla/processmail +++ b/mozilla/webtools/bugzilla/processmail @@ -51,7 +51,7 @@ my %nomail; my @excludedAddresses = (); # disable email flag for offline debugging work -my $enableSendMail = 1; +my $enableSendMail = 0; my %force; @{$force{'QAcontact'}} = (); diff --git a/mozilla/webtools/bugzilla/queryhelp.cgi b/mozilla/webtools/bugzilla/queryhelp.cgi index 89db7b5cb31..16acf73f1f1 100755 --- a/mozilla/webtools/bugzilla/queryhelp.cgi +++ b/mozilla/webtools/bugzilla/queryhelp.cgi @@ -660,7 +660,7 @@ print qq{ }; -SendSQL("SELECT product,description FROM products ORDER BY product"); +SendSQL("SELECT name, description FROM products ORDER BY name"); while (MoreSQLData()) { my ($product, $productdesc) = FetchSQLData(); @@ -725,7 +725,11 @@ components and their associated products: foreach $product (@products) { - SendSQL("SELECT value,description FROM components WHERE program=" . SqlQuote($product) . " ORDER BY value"); + SendSQL("SELECT components.name, components.description " . + "FROM components, products " . + "WHERE components.product_id = products.id" . + " AND products.name = " . SqlQuote($product) . + "ORDER BY name"); while (MoreSQLData()) { diff --git a/mozilla/webtools/bugzilla/reports.cgi b/mozilla/webtools/bugzilla/reports.cgi index e04a9fd6d49..ac77c89fd90 100755 --- a/mozilla/webtools/bugzilla/reports.cgi +++ b/mozilla/webtools/bugzilla/reports.cgi @@ -263,6 +263,7 @@ $when

FIN # Build up $query string + my $prod_table = ($FORM{'product'} ne "-All-") ? ", products" : ""; my $query; $query = <\n

"; if( $FORM{'product'} ne "-All-" ) { - SendSQL("SELECT defaultmilestone FROM products WHERE product = " . - SqlQuote($FORM{'product'})); + SendSQL("SELECT defaultmilestone FROM products WHERE id = $product_id"); $ms = FetchOneColumn(); print "Most Doomed for $ms ($FORM{'product'})"; } else { @@ -661,7 +663,7 @@ sub most_doomed_for_milestone { my $query; $query = "select distinct assigned_to from bugs where target_milestone=\"$ms\""; if ($FORM{'product'} ne "-All-" ) { - $query .= "and bugs.product=".SqlQuote($FORM{'product'}); + $query .= "and bugs.product_id=$product_id "; } $query .= <bug list)}); + Alert(qq{Bug(s) found with invalid product/component ID: $product_id/$component_id}); } } @@ -587,7 +585,7 @@ Status("Checking votes/everconfirmed"); @badbugs = (); SendSQL("SELECT bug_id FROM bugs, products " . - "WHERE bugs.product = products.product " . + "WHERE bugs.product_id = products.id " . "AND bug_status = " . SqlQuote($::unconfirmedstate) . ' ' . "AND votestoconfirm <= votes " . "ORDER BY bug_id"); diff --git a/mozilla/webtools/bugzilla/votes.cgi b/mozilla/webtools/bugzilla/votes.cgi index 8f58605f4fc..dbc0f960729 100755 --- a/mozilla/webtools/bugzilla/votes.cgi +++ b/mozilla/webtools/bugzilla/votes.cgi @@ -152,7 +152,7 @@ sub show_user { # we can do it all in one query. my %maxvotesperbug; if($canedit) { - SendSQL("SELECT products.product, products.maxvotesperbug + SendSQL("SELECT products.name, products.maxvotesperbug FROM products"); while (MoreSQLData()) { my ($prod, $max) = FetchSQLData(); @@ -172,10 +172,11 @@ sub show_user { SendSQL("SELECT votes.bug_id, votes.count, bugs.short_desc, bugs.bug_status - FROM votes, bugs + FROM votes, bugs, products WHERE votes.who = $who AND votes.bug_id = bugs.bug_id - AND bugs.product = " . SqlQuote($product) . + AND bugs.product_id = products.id + AND products.name = " . SqlQuote($product) . "ORDER BY votes.bug_id"); while (MoreSQLData()) { @@ -269,9 +270,9 @@ sub record_votes { # If the user is voting for bugs, make sure they aren't overstuffing # the ballot box. if (scalar(@buglist)) { - SendSQL("SELECT bugs.bug_id, bugs.product, products.maxvotesperbug + SendSQL("SELECT bugs.bug_id, products.name, products.maxvotesperbug FROM bugs, products - WHERE products.product = bugs.product + WHERE products.id = bugs.product_id AND bugs.bug_id IN (" . join(", ", @buglist) . ")"); my %prodcount;