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|