From e92cc4c9b115dfae6e352660c053e142634a3ef4 Mon Sep 17 00:00:00 2001 From: "mkanat%kerio.com" <> Date: Fri, 25 Feb 2005 06:43:28 +0000 Subject: Bug 17453: Enumerators in Bugzilla are not cross-DB compatible. This removes all 'enum' types in the database from Bugzilla. Patch By Max Kanat-Alexander r=joel, a=justdave --- globals.pl | 39 ++++++++++++++++----------------------- 1 file changed, 16 insertions(+), 23 deletions(-) (limited to 'globals.pl') diff --git a/globals.pl b/globals.pl index 9ea60c48b..f6f15566d 100644 --- a/globals.pl +++ b/globals.pl @@ -22,7 +22,9 @@ # Jacob Steenhagen # Bradley Baetz # Christopher Aillon -# Joel Peshkin +# Joel Peshkin +# Dave Lawrence +# Max Kanat-Alexander # Contains some global variables and routines used throughout bugzilla. @@ -225,12 +227,12 @@ sub GenerateVersionTable { } @::log_columns = (sort(@::log_columns)); - @::legal_priority = SplitEnumType($cols->{"priority,type"}); - @::legal_severity = SplitEnumType($cols->{"bug_severity,type"}); - @::legal_platform = SplitEnumType($cols->{"rep_platform,type"}); - @::legal_opsys = SplitEnumType($cols->{"op_sys,type"}); - @::legal_bug_status = SplitEnumType($cols->{"bug_status,type"}); - @::legal_resolution = SplitEnumType($cols->{"resolution,type"}); + @::legal_priority = get_legal_field_values("priority"); + @::legal_severity = get_legal_field_values("bug_severity"); + @::legal_platform = get_legal_field_values("rep_platform"); + @::legal_opsys = get_legal_field_values("op_sys"); + @::legal_bug_status = get_legal_field_values("bug_status"); + @::legal_resolution = get_legal_field_values("resolution"); # 'settable_resolution' is the list of resolutions that may be set # directly by hand in the bug form. Start with the list of legal @@ -1026,22 +1028,13 @@ sub LearnAboutColumns { return \%a; } - - -# If the above returned a enum type, take that type and parse it into the -# list of values. Assumes that enums don't ever contain an apostrophe! - -sub SplitEnumType { - my ($str) = (@_); - my @result = (); - if ($str =~ /^enum\((.*)\)$/) { - my $guts = $1 . ","; - while ($guts =~ /^\'([^\']*)\',(.*)$/) { - push @result, $1; - $guts = $2; - } - } - return @result; +# Returns a list of all the legal values for a field that has a +# list of legal values, like rep_platform or resolution. +sub get_legal_field_values { + my ($field) = @_; + my $dbh = Bugzilla->dbh; + my $result_ref = $dbh->selectcol_arrayref("SELECT value FROM $field"); + return @$result_ref; } sub UserInGroup { -- cgit v1.2.3-24-g4f1b