From 4560c2324d978970871bfbe6a9480b17a915342f Mon Sep 17 00:00:00 2001 From: "cyeh%bluemartini.com" <> Date: Fri, 23 Feb 2001 02:11:22 +0000 Subject: fix for 66876: Using userids (mediumint) for initialowner and initialqacontact based on patch submitted by baulig@suse.de (Martin Baulig). --- checksetup.pl | 64 +++++++++++++++++++++++++++++++++++-- describecomponents.cgi | 10 ++++-- editcomponents.cgi | 87 +++++++++++++++++++++++++++++++++++++------------- editusers.cgi | 4 +-- post_bug.cgi | 5 ++- process_bug.cgi | 9 +++--- sanitycheck.cgi | 7 ++-- 7 files changed, 145 insertions(+), 41 deletions(-) diff --git a/checksetup.pl b/checksetup.pl index 8b8054081..11993e525 100755 --- a/checksetup.pl +++ b/checksetup.pl @@ -755,8 +755,8 @@ $table{longdescs} = $table{components} = 'value tinytext, program varchar(64), - initialowner tinytext not null, # Should arguably be a mediumint! - initialqacontact tinytext not null, # Should arguably be a mediumint! + initialowner mediumint not null, + initialqacontact mediumint not null, description mediumtext not null'; @@ -1824,6 +1824,66 @@ my @resolutions = ("", "FIXED", "INVALID", "WONTFIX", "LATER", "REMIND", "DUPLICATE", "WORKSFORME", "MOVED"); CheckEnumField('bugs', 'resolution', @resolutions); +if (($_ = GetFieldDef('components', 'initialowner')) and ($_->[1] eq 'tinytext')) { + $sth = $dbh->prepare("SELECT program, value, initialowner, initialqacontact FROM components"); + $sth->execute(); + while (my ($program, $value, $initialowner) = $sth->fetchrow_array()) { + $initialowner =~ s/([\\\'])/\\$1/g; $initialowner =~ s/\0/\\0/g; + $program =~ s/([\\\'])/\\$1/g; $program =~ s/\0/\\0/g; + $value =~ s/([\\\'])/\\$1/g; $value =~ s/\0/\\0/g; + + my $s2 = $dbh->prepare("SELECT userid FROM profiles WHERE login_name = '$initialowner'"); + $s2->execute(); + + my $initialownerid = $s2->fetchrow_array(); + + unless (defined $initialownerid) { + print "Warning: You have an invalid initial owner '$initialowner' in program '$program', component '$value'!\n"; + $initialownerid = 0; + } + + my $update = "UPDATE components SET initialowner = $initialownerid ". + "WHERE program = '$program' AND value = '$value'"; + my $s3 = $dbh->prepare("UPDATE components SET initialowner = $initialownerid ". + "WHERE program = '$program' AND value = '$value';"); + $s3->execute(); + } + + ChangeFieldType('components','initialowner','mediumint'); +} + +if (($_ = GetFieldDef('components', 'initialqacontact')) and ($_->[1] eq 'tinytext')) { + $sth = $dbh->prepare("SELECT program, value, initialqacontact, initialqacontact FROM components"); + $sth->execute(); + while (my ($program, $value, $initialqacontact) = $sth->fetchrow_array()) { + $initialqacontact =~ s/([\\\'])/\\$1/g; $initialqacontact =~ s/\0/\\0/g; + $program =~ s/([\\\'])/\\$1/g; $program =~ s/\0/\\0/g; + $value =~ s/([\\\'])/\\$1/g; $value =~ s/\0/\\0/g; + + my $s2 = $dbh->prepare("SELECT userid FROM profiles WHERE login_name = '$initialqacontact'"); + $s2->execute(); + + my $initialqacontactid = $s2->fetchrow_array(); + + unless (defined $initialqacontactid) { + if ($initialqacontact ne '') { + print "Warning: You have an invalid initial QA contact '$initialqacontact' in program '$program', component '$value'!\n"; + } + $initialqacontactid = 0; + } + + my $update = "UPDATE components SET initialqacontact = $initialqacontactid ". + "WHERE program = '$program' AND value = '$value'"; + my $s3 = $dbh->prepare("UPDATE components SET initialqacontact = $initialqacontactid ". + "WHERE program = '$program' AND value = '$value';"); + $s3->execute(); + } + + ChangeFieldType('components','initialqacontact','mediumint'); +} + + + my @states = ("UNCONFIRMED", "NEW", "ASSIGNED", "REOPENED", "RESOLVED", "VERIFIED", "CLOSED"); CheckEnumField('bugs', 'bug_status', @states); diff --git a/describecomponents.cgi b/describecomponents.cgi index e1b646f51..4353af2fc 100755 --- a/describecomponents.cgi +++ b/describecomponents.cgi @@ -78,9 +78,15 @@ print ""; SendSQL("select value, initialowner, initialqacontact, description from components where program = " . SqlQuote($product) . " order by value"); +my @data; while (MoreSQLData()) { - my @row = FetchSQLData(); - my ($component, $initialowner, $initialqacontact, $description) = (@row); + push @data, [FetchSQLData()]; +} +foreach (@data) { + my ($component, $initialownerid, $initialqacontactid, $description) = @$_; + + my ($initialowner, $initialqacontact) = ($initialownerid ? DBID_to_name ($initialownerid) : '', + $initialqacontactid ? DBID_to_name ($initialqacontactid) : ''); print qq|
diff --git a/editcomponents.cgi b/editcomponents.cgi index 4714a4d8a..dcca05bba 100755 --- a/editcomponents.cgi +++ b/editcomponents.cgi @@ -116,7 +116,10 @@ sub CheckComponent ($$) sub EmitFormElements ($$$$$) { - my ($product, $component, $initialowner, $initialqacontact, $description) = @_; + my ($product, $component, $initialownerid, $initialqacontactid, $description) = @_; + + my ($initialowner, $initialqacontact) = ($initialownerid ? DBID_to_name ($initialownerid) : '', + $initialqacontactid ? DBID_to_name ($initialqacontactid) : ''); print " Component:\n"; print " Delete\n"; print ""; - while ( MoreSQLData() ) { - my ($component,$desc,$initialowner,$initialqacontact, $bugs) = FetchSQLData(); + my @data; + while (MoreSQLData()) { + push @data, [FetchSQLData()]; + } + foreach (@data) { + my ($component,$desc,$initialownerid,$initialqacontactid, $bugs) = @$_; + $desc ||= "missing"; - $initialowner ||= "missing"; - $initialqacontact ||= "none"; + my $initialowner = $initialownerid ? DBID_to_name ($initialownerid) : "missing"; + my $initialqacontact = $initialqacontactid ? DBID_to_name ($initialqacontactid) : "missing"; print "\n"; print " $component\n"; print " $desc\n"; @@ -338,7 +346,7 @@ if ($action eq 'add') { print "
\n"; print "\n"; - EmitFormElements($product, '', '', '', ''); + EmitFormElements($product, '', 0, 0, ''); print "
\n
\n"; print "\n"; @@ -398,7 +406,17 @@ if ($action eq 'new') { exit; } + my $initialownerid = DBname_to_id ($initialowner); + if (!$initialownerid) { + print "You must use an existing Bugzilla account as initial owner for the component +'$component'. Please press\n"; + print "Back and try again.\n"; + PutTrailer($localtrailer); + exit; + } + my $initialqacontact = trim($::FORM{initialqacontact} || ''); + my $initialqacontactid = DBname_to_id ($initialqacontact); if (Param('useqacontact')) { if ($initialqacontact eq '') { print "You must enter an initial QA contact for the component '$component'. Please press\n"; @@ -406,6 +424,13 @@ if ($action eq 'new') { PutTrailer($localtrailer); exit; } + + if (!$initialqacontactid) { + print "You must use an existing Bugzilla account as initial QA contact for the component '$component'. Please press\n"; + print "Back and try again.\n"; + PutTrailer($localtrailer); + exit; + } # # Now validating to make sure it's too an existing account # @@ -419,8 +444,8 @@ if ($action eq 'new') { SqlQuote($product) . "," . SqlQuote($component) . "," . SqlQuote($description) . "," . - SqlQuote($initialowner) . "," . - SqlQuote($initialqacontact) . ")"); + SqlQuote($initialownerid) . "," . + SqlQuote($initialqacontactid) . ")"); # Make versioncache flush unlink "data/versioncache"; @@ -458,13 +483,14 @@ if ($action eq 'del') { my ($product,$pdesc,$milestoneurl,$disallownew, - $dummy,$component,$initialowner,$initialqacontact,$cdesc) = FetchSQLData(); + $dummy,$component,$initialownerid,$initialqacontactid,$cdesc) = FetchSQLData(); + + my $initialowner = $initialownerid ? DBID_to_name ($initialownerid) : "missing"; + my $initialqacontact = $initialqacontactid ? DBID_to_name ($initialqacontactid) : "missing"; $pdesc ||= "missing"; $milestoneurl ||= "missing"; $disallownew = $disallownew ? 'closed' : 'open'; - $initialowner ||= "missing"; - $initialqacontact ||= "missing"; $cdesc ||= "missing"; print "\n"; @@ -637,14 +663,17 @@ if ($action eq 'edit') { AND value=" . SqlQuote($component) ); my ($product,$pdesc,$milestoneurl,$disallownew, - $dummy,$component,$initialowner,$initialqacontact,$cdesc) = FetchSQLData(); + $dummy,$component,$initialownerid,$initialqacontactid,$cdesc) = FetchSQLData(); + + my $initialowner = $initialownerid ? DBID_to_name ($initialownerid) : ''; + my $initialqacontact = $initialqacontactid ? DBID_to_name ($initialqacontactid) : ''; print "\n"; print "
\n"; #+++ display product/product description - EmitFormElements($product, $component, $initialowner, $initialqacontact, $cdesc); + EmitFormElements($product, $component, $initialownerid, $initialqacontactid, $cdesc); print "\n"; print " \n"; @@ -701,7 +730,7 @@ if ($action eq 'update') { # them, be sure to test for WHERE='$component' or WHERE='$componentold' SendSQL("LOCK TABLES bugs WRITE, - components WRITE"); + components WRITE, profiles READ"); if ($description ne $descriptionold) { unless ($description) { @@ -721,14 +750,21 @@ if ($action eq 'update') { if ($initialowner ne $initialownerold) { unless ($initialowner) { print "Sorry, I can't delete the initial owner."; - PutTrailer($localtrailer); SendSQL("UNLOCK TABLES"); + PutTrailer($localtrailer); exit; } - #+++ - #DBNameToIdAndCheck($initialowner, 0); + + my $initialownerid = DBname_to_id($initialowner); + unless ($initialownerid) { + print "Sorry, you must use an existing Bugzilla account as initial owner."; + SendSQL("UNLOCK TABLES"); + PutTrailer($localtrailer); + exit; + } + SendSQL("UPDATE components - SET initialowner=" . SqlQuote($initialowner) . " + SET initialowner=" . SqlQuote($initialownerid) . " WHERE program=" . SqlQuote($product) . " AND value=" . SqlQuote($componentold)); print "Updated initial owner.
\n"; @@ -737,14 +773,21 @@ if ($action eq 'update') { if (Param('useqacontact') && $initialqacontact ne $initialqacontactold) { unless ($initialqacontact) { print "Sorry, I can't delete the initial QA contact."; - PutTrailer($localtrailer); SendSQL("UNLOCK TABLES"); + PutTrailer($localtrailer); exit; } - #+++ - #DBNameToIdAndCheck($initialqacontact, 0); + + my $initialqacontactid = DBname_to_id($initialqacontact); + unless ($initialqacontactid) { + print "Sorry, you must use an existing Bugzilla account as initial QA contact."; + SendSQL("UNLOCK TABLES"); + PutTrailer($localtrailer); + exit; + } + SendSQL("UPDATE components - SET initialqacontact=" . SqlQuote($initialqacontact) . " + SET initialqacontact=" . SqlQuote($initialqacontactid) . " WHERE program=" . SqlQuote($product) . " AND value=" . SqlQuote($componentold)); print "Updated initial QA contact.
\n"; diff --git a/editusers.cgi b/editusers.cgi index 72e42f03d..319b2ea79 100755 --- a/editusers.cgi +++ b/editusers.cgi @@ -566,7 +566,7 @@ if ($action eq 'del') { SendSQL("SELECT program, value FROM components - WHERE initialowner=" . SqlQuote($user)); + WHERE initialowner=" . DBname_to_id($user)); $found = 0; while (MoreSQLData()) { if ($found) { @@ -590,7 +590,7 @@ if ($action eq 'del') { SendSQL("SELECT program, value FROM components - WHERE initialqacontact=" . SqlQuote($user)); + WHERE initialqacontact=" . DBname_to_id($user)); $found = 0; while (MoreSQLData()) { if ($found) { diff --git a/post_bug.cgi b/post_bug.cgi index a9878ba6a..ae1ba4c7c 100755 --- a/post_bug.cgi +++ b/post_bug.cgi @@ -101,7 +101,6 @@ if ($::FORM{'assigned_to'} eq "") { $forceAssignedOK = 1; } -$::FORM{'assigned_to'} = DBNameToIdAndCheck($::FORM{'assigned_to'}, $forceAssignedOK); $::FORM{'reporter'} = DBNameToIdAndCheck($::FORM{'reporter'}); @@ -115,8 +114,8 @@ if (Param("useqacontact")) { SqlQuote($::FORM{'product'}) . " and value=" . SqlQuote($::FORM{'component'})); my $qacontact = FetchOneColumn(); - if (defined $qacontact && $qacontact ne "") { - $::FORM{'qa_contact'} = DBNameToIdAndCheck($qacontact, 1); + if (defined $qacontact && $qacontact != 0) { + $::FORM{'qa_contact'} = $qacontact; push(@bug_fields, "qa_contact"); } } diff --git a/process_bug.cgi b/process_bug.cgi index ba4b2335b..f27961aef 100755 --- a/process_bug.cgi +++ b/process_bug.cgi @@ -489,8 +489,8 @@ SWITCH: for ($::FORM{'knob'}) { SendSQL("select initialowner from components where program=" . SqlQuote($::FORM{'product'}) . " and value=" . SqlQuote($::FORM{'component'})); - my $newname = FetchOneColumn(); - my $newid = DBNameToIdAndCheck($newname, 1); + my $newid = FetchOneColumn(); + my $newname = DBID_to_name($newid); DoComma(); $::query .= "assigned_to = $newid"; if (Param("useqacontact")) { @@ -498,10 +498,9 @@ SWITCH: for ($::FORM{'knob'}) { SqlQuote($::FORM{'product'}) . " and value=" . SqlQuote($::FORM{'component'})); my $qacontact = FetchOneColumn(); - if (defined $qacontact && $qacontact ne "") { - my $newqa = DBNameToIdAndCheck($qacontact, 1); + if (defined $qacontact && $qacontact != 0) { DoComma(); - $::query .= "qa_contact = $newqa"; + $::query .= "qa_contact = $qacontact"; } } last SWITCH; diff --git a/sanitycheck.cgi b/sanitycheck.cgi index d19206cdd..bcd1716a6 100755 --- a/sanitycheck.cgi +++ b/sanitycheck.cgi @@ -146,11 +146,8 @@ CrossCheck("profiles", "userid", ["cc", "who", "bug_id"], ["votes", "who", "bug_id"], ["longdescs", "who", "bug_id"], - ["namedqueries", "userid"]); - -CrossCheck("profiles", "login_name", - ["components", "initialowner"]),; - + ["namedqueries", "userid"], + ["components", "initialowner"]); Status("Checking passwords"); SendSQL("SELECT COUNT(*) FROM profiles WHERE cryptpassword != ENCRYPT(password, left(cryptpassword, 2))"); -- cgit v1.2.3-24-g4f1b
Bugs: