diff options
author | 2006-08-04 07:40:49 +0000 | |
---|---|---|
committer | 2006-08-04 07:40:49 +0000 | |
commit | e68208dd74f630691a541c6dba5783ccbe0f0b40 (patch) | |
tree | c2978bdc53ee5b0b441ee972b58b4953b395e296 /checksetup.pl | |
parent | Bug 345929: User matching not called for requestee fields in post_bug.cgi - P... (diff) | |
download | bugzilla-e68208dd74f630691a541c6dba5783ccbe0f0b40.tar.gz bugzilla-e68208dd74f630691a541c6dba5783ccbe0f0b40.tar.bz2 bugzilla-e68208dd74f630691a541c6dba5783ccbe0f0b40.zip |
Bug 347116: Move field-definition code from checksetup.pl into a module
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> (module owner) a=myk
Diffstat (limited to 'checksetup.pl')
-rwxr-xr-x | checksetup.pl | 138 |
1 files changed, 1 insertions, 137 deletions
diff --git a/checksetup.pl b/checksetup.pl index 15db11053..ed670a271 100755 --- a/checksetup.pl +++ b/checksetup.pl @@ -455,71 +455,6 @@ sub AddGroup { return $last; } - -########################################################################### -# The list of fields. -########################################################################### - -# NOTE: All of these entries are unconditional, from when get_field_id -# used to create an entry if it wasn't found. New fielddef columns should -# be created with their associated schema change. -use constant OLD_FIELD_DEFS => ( - {name => 'bug_id', desc => 'Bug #', in_new_bugmail => 1}, - {name => 'short_desc', desc => 'Summary', in_new_bugmail => 1}, - {name => 'classification', desc => 'Classification', in_new_bugmail => 1}, - {name => 'product', desc => 'Product', in_new_bugmail => 1}, - {name => 'version', desc => 'Version', in_new_bugmail => 1}, - {name => 'rep_platform', desc => 'Platform', in_new_bugmail => 1}, - {name => 'bug_file_loc', desc => 'URL', in_new_bugmail => 1}, - {name => 'op_sys', desc => 'OS/Version', in_new_bugmail => 1}, - {name => 'bug_status', desc => 'Status', in_new_bugmail => 1}, - {name => 'status_whiteboard', desc => 'Status Whiteboard', - in_new_bugmail => 1}, - {name => 'keywords', desc => 'Keywords', in_new_bugmail => 1}, - {name => 'resolution', desc => 'Resolution'}, - {name => 'bug_severity', desc => 'Severity', in_new_bugmail => 1}, - {name => 'priority', desc => 'Priority', in_new_bugmail => 1}, - {name => 'component', desc => 'Component', in_new_bugmail => 1}, - {name => 'assigned_to', desc => 'AssignedTo', in_new_bugmail => 1}, - {name => 'reporter', desc => 'ReportedBy', in_new_bugmail => 1}, - {name => 'votes', desc => 'Votes'}, - {name => 'qa_contact', desc => 'QAContact', in_new_bugmail => 1}, - {name => 'cc', desc => 'CC', in_new_bugmail => 1}, - {name => 'dependson', desc => 'BugsThisDependsOn', in_new_bugmail => 1}, - {name => 'blocked', desc => 'OtherBugsDependingOnThis', - in_new_bugmail => 1}, - - {name => 'attachments.description', desc => 'Attachment description'}, - {name => 'attachments.filename', desc => 'Attachment filename'}, - {name => 'attachments.mimetype', desc => 'Attachment mime type'}, - {name => 'attachments.ispatch', desc => 'Attachment is patch'}, - {name => 'attachments.isobsolete', desc => 'Attachment is obsolete'}, - {name => 'attachments.isprivate', desc => 'Attachment is private'}, - - {name => 'target_milestone', desc => 'Target Milestone'}, - {name => 'creation_ts', desc => 'Creation date', in_new_bugmail => 1}, - {name => 'delta_ts', desc => 'Last changed date', in_new_bugmail => 1}, - {name => 'longdesc', desc => 'Comment'}, - {name => 'alias', desc => 'Alias'}, - {name => 'everconfirmed', desc => 'Ever Confirmed'}, - {name => 'reporter_accessible', desc => 'Reporter Accessible'}, - {name => 'cclist_accessible', desc => 'CC Accessible'}, - {name => 'bug_group', desc => 'Group'}, - {name => 'estimated_time', desc => 'Estimated Hours', in_new_bugmail => 1}, - {name => 'remaining_time', desc => 'Remaining Hours'}, - {name => 'deadline', desc => 'Deadline', in_new_bugmail => 1}, - {name => 'commenter', desc => 'Commenter'}, - {name => 'flagtypes.name', desc => 'Flag'}, - {name => 'requestees.login_name', desc => 'Flag Requestee'}, - {name => 'setters.login_name', desc => 'Flag Setter'}, - {name => 'work_time', desc => 'Hours Worked'}, - {name => 'percentage_complete', desc => 'Percentage Complete'}, - {name => 'content', desc => 'Content'}, - {name => 'attach_data.thedata', desc => 'Attachment data'}, - {name => 'attachments.isurl', desc => 'Attachment is a URL'} -); -# Please see comment above before adding any new values to this constant. - ########################################################################### # Changes to the fielddefs --TABLE-- ########################################################################### @@ -529,78 +464,7 @@ use constant OLD_FIELD_DEFS => ( # these particular schema changes before we make any other schema changes. Bugzilla::Install::DB::update_fielddefs_definition(); -# Create field definitions -foreach my $definition (OLD_FIELD_DEFS) { - Bugzilla::Field::create_or_update($definition); -} - -# Delete or adjust old field definitions. - -# Oops. Bug 163299 -$dbh->do("DELETE FROM fielddefs WHERE name='cc_accessible'"); -# Oops. Bug 215319 -$dbh->do("DELETE FROM fielddefs WHERE name='requesters.login_name'"); -# This field was never tracked in bugs_activity, so it's safe to delete. -$dbh->do("DELETE FROM fielddefs WHERE name='attachments.thedata'"); - -# 2005-11-13 LpSolit@gmail.com - Bug 302599 -# One of the field names was a fragment of SQL code, which is DB dependent. -# We have to rename it to a real name, which is DB independent. -my $new_field_name = 'days_elapsed'; -my $field_description = 'Days since bug changed'; - -my ($old_field_id, $old_field_name) = - $dbh->selectrow_array('SELECT id, name - FROM fielddefs - WHERE description = ?', - undef, $field_description); - -if ($old_field_id && ($old_field_name ne $new_field_name)) { - print "SQL fragment found in the 'fielddefs' table...\n"; - print "Old field name: " . $old_field_name . "\n"; - # We have to fix saved searches first. Queries have been escaped - # before being saved. We have to do the same here to find them. - $old_field_name = url_quote($old_field_name); - my $broken_named_queries = - $dbh->selectall_arrayref('SELECT userid, name, query - FROM namedqueries WHERE ' . - $dbh->sql_istrcmp('query', '?', 'LIKE'), - undef, "%=$old_field_name%"); - - my $sth_UpdateQueries = $dbh->prepare('UPDATE namedqueries SET query = ? - WHERE userid = ? AND name = ?'); - - print "Fixing saved searches...\n" if scalar(@$broken_named_queries); - foreach my $named_query (@$broken_named_queries) { - my ($userid, $name, $query) = @$named_query; - $query =~ s/=\Q$old_field_name\E(&|$)/=$new_field_name$1/gi; - $sth_UpdateQueries->execute($query, $userid, $name); - } - - # We now do the same with saved chart series. - my $broken_series = - $dbh->selectall_arrayref('SELECT series_id, query - FROM series WHERE ' . - $dbh->sql_istrcmp('query', '?', 'LIKE'), - undef, "%=$old_field_name%"); - - my $sth_UpdateSeries = $dbh->prepare('UPDATE series SET query = ? - WHERE series_id = ?'); - - print "Fixing saved chart series...\n" if scalar(@$broken_series); - foreach my $series (@$broken_series) { - my ($series_id, $query) = @$series; - $query =~ s/=\Q$old_field_name\E(&|$)/=$new_field_name$1/gi; - $sth_UpdateSeries->execute($query, $series_id); - } - # Now that saved searches have been fixed, we can fix the field name. - print "Fixing the 'fielddefs' table...\n"; - print "New field name: " . $new_field_name . "\n"; - $dbh->do('UPDATE fielddefs SET name = ? WHERE id = ?', - undef, ($new_field_name, $old_field_id)); -} -Bugzilla::Field::create_or_update( - {name => $new_field_name, desc => $field_description}); +Bugzilla::Field::populate_field_definitions(); ########################################################################### # Create initial test product if there are no products present. |