From 8da7f321aabe95470944bc23aeed9a06ef6793a5 Mon Sep 17 00:00:00 2001 From: "justdave%bugzilla.org" <> Date: Sun, 15 Apr 2007 06:35:56 +0000 Subject: Bug 373869: Custom field names must be all lowercase or buglist.cgi sorting throws an error Patch by mkanat and justdave r=LpSolit,mkanat; a=mkanat --- Bugzilla/Install/DB.pm | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'Bugzilla/Install') diff --git a/Bugzilla/Install/DB.pm b/Bugzilla/Install/DB.pm index 96bc161ac..f05f1722e 100644 --- a/Bugzilla/Install/DB.pm +++ b/Bugzilla/Install/DB.pm @@ -503,6 +503,8 @@ sub update_table_definitions { $dbh->bz_add_column('milestones', 'id', {TYPE => 'MEDIUMSERIAL', NOTNULL => 1, PRIMARYKEY => 1}); + _fix_uppercase_custom_field_names(); + ################################################################ # New --TABLE-- changes should go *** A B O V E *** this point # ################################################################ @@ -2732,6 +2734,25 @@ sub _update_longdescs_who_index { } } +sub _fix_uppercase_custom_field_names { + # Before the final release of 3.0, custom fields could be + # created with mixed-case names. + my $dbh = Bugzilla->dbh; + my $fields = $dbh->selectall_arrayref( + 'SELECT name, type FROM fielddefs WHERE custom = 1'); + foreach my $row (@$fields) { + my ($name, $type) = @$row; + if ($name ne lc($name)) { + $dbh->bz_rename_column('bugs', $name, lc($name)); + $dbh->bz_rename_table($name, lc($name)) + if $type == FIELD_TYPE_SINGLE_SELECT; + $dbh->do('UPDATE fielddefs SET name = ? WHERE name = ?', + undef, lc($name), $name); + } + } + +} + 1; __END__ -- cgit v1.2.1