From 08136a9c69356aa71b7c6e821b8c5f1892c9b0fd Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Mon, 14 Apr 2014 18:42:55 +0400 Subject: [PATCH] Mostly remove bug_status hardcode, fix some more SQL queries for new schema --- Bugzilla/Bug.pm | 2 +- Bugzilla/DB.pm | 2 +- Bugzilla/Field/Choice.pm | 11 --- Bugzilla/Install/DB.pm | 6 ++ Bugzilla/Milestone.pm | 75 ++++++++----------- Bugzilla/Search/Quicksearch.pm | 4 +- Bugzilla/Status.pm | 19 +++-- Bugzilla/Template.pm | 3 +- Bugzilla/User.pm | 14 ++-- Bugzilla/Version.pm | 44 ++++------- buglist.cgi | 4 +- collectstats.pl | 8 +- duplicates.cgi | 3 +- editproducts.cgi | 1 + editvalues.cgi | 17 ++--- editworkflow.cgi | 2 +- enter_bug.cgi | 7 +- importxml.pl | 9 ++- sanitycheck.cgi | 1 + showdependencygraph.cgi | 49 +++++------- skins/standard/buglist.css | 1 + skins/standard/global.css | 1 + .../en/default/account/prefs/email.html.tmpl | 2 +- .../default/admin/fieldvalues/edit.html.tmpl | 28 +++++-- .../admin/products/edit-common.html.tmpl | 5 +- .../default/admin/products/updated.html.tmpl | 13 ++-- .../en/default/admin/workflow/edit.html.tmpl | 3 +- .../en/default/attachment/create.html.tmpl | 20 +++-- .../en/default/bug/dependency-graph.html.tmpl | 1 + template/en/default/bug/knob.html.tmpl | 5 +- .../en/default/global/code-error.html.tmpl | 3 +- template/en/default/global/messages.html.tmpl | 7 ++ .../en/default/list/edit-multiple.html.tmpl | 3 +- template/en/default/list/list.ics.tmpl | 10 ++- whineatnews.pl | 62 +++++++-------- 35 files changed, 217 insertions(+), 228 deletions(-) diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm index 8905ae50c..b8e433791 100644 --- a/Bugzilla/Bug.pm +++ b/Bugzilla/Bug.pm @@ -2855,7 +2855,7 @@ sub statuses_available } # *Only* users with (product-specific) "canconfirm" privs can confirm bugs. - if (!$self->status->is_confirmed && !$user->in_group('canconfirm', $self->product_id)) + if (!$self->status->is_confirmed && !Bugzilla->user->in_group('canconfirm', $self->product_id)) { @statuses = grep { !$_->is_confirmed } @statuses; } diff --git a/Bugzilla/DB.pm b/Bugzilla/DB.pm index f9c681ab3..0b3b3fdfe 100644 --- a/Bugzilla/DB.pm +++ b/Bugzilla/DB.pm @@ -1431,7 +1431,7 @@ Bugzilla::DB - Database access routines, using L # prepare a query using DB methods my $sth = $dbh->prepare("SELECT " . $dbh->sql_date_format("creation_ts", "%Y%m%d") . - " FROM bugs WHERE bug_status != 'RESOLVED' " . + " FROM bugs WHERE bug_status != 4 " . $dbh->sql_limit(1)); # Execute the query diff --git a/Bugzilla/Field/Choice.pm b/Bugzilla/Field/Choice.pm index 42c86cdf1..4d9cba9b5 100644 --- a/Bugzilla/Field/Choice.pm +++ b/Bugzilla/Field/Choice.pm @@ -157,17 +157,6 @@ sub update if (exists $changes->{$self->NAME_FIELD}) { my ($old, $new) = @{ $changes->{$self->NAME_FIELD} }; - if ($self->field->type != FIELD_TYPE_MULTI_SELECT) - { - $self->field->{has_activity} = 1; - $dbh->do( - "INSERT INTO bugs_activity (bug_id, who, bug_when, fieldid, added, removed)". - " SELECT bug_id, ?, NOW(), ?, ?, ? FROM bugs WHERE $fname = ?", undef, - Bugzilla->user->id, $self->field->id, $new, $old, $old - ); - $dbh->do("UPDATE bugs SET $fname = ?, lastdiffed = NOW() WHERE $fname = ?", - undef, $new, $old); - } if ($old_self->is_default) { my $param = $self->DEFAULT_MAP->{$self->field->name}; diff --git a/Bugzilla/Install/DB.pm b/Bugzilla/Install/DB.pm index d5b5f18af..9116e0e6e 100644 --- a/Bugzilla/Install/DB.pm +++ b/Bugzilla/Install/DB.pm @@ -715,6 +715,12 @@ WHERE description LIKE\'%[CC:%\''); $dbh->bz_add_fk('bugs', $_->name, { TABLE => 'bugs', COLUMN => 'bug_id' }); } + # Add is_assigned and is_confirmed columns to bug_status table + $dbh->bz_add_column('bug_status', is_assigned => {TYPE => 'BOOLEAN', NOTNULL => 1, DEFAULT => 'TRUE'}); + $dbh->bz_add_column('bug_status', is_confirmed => {TYPE => 'BOOLEAN', NOTNULL => 1, DEFAULT => 'TRUE'}); + $dbh->do('UPDATE bug_status SET is_assigned=0 WHERE NOT value=?', undef, 'ASSIGNED'); + $dbh->do('UPDATE bug_status SET is_confirmed=0 WHERE value=?', undef, 'UNCONFIRMED'); + ################################################################ # New --TABLE-- changes should go *** A B O V E *** this point # ################################################################ diff --git a/Bugzilla/Milestone.pm b/Bugzilla/Milestone.pm index ba7c943c0..837bebe99 100644 --- a/Bugzilla/Milestone.pm +++ b/Bugzilla/Milestone.pm @@ -128,30 +128,8 @@ sub update my $dbh = Bugzilla->dbh; $dbh->bz_start_transaction(); - # Not Bugzilla::Field::Choice! It will overwrite other products' bug values my ($changes, $old_self) = Bugzilla::Object::update($self, @_); - if (exists $changes->{value}) - { - # Record activity - $self->field->{has_activity} = 1; - $dbh->do( - 'INSERT INTO bugs_activity (bug_id, who, bug_when, fieldid, added, removed)'. - ' SELECT bug_id, ?, NOW(), ?, ?, ? FROM bugs WHERE target_milestone = ? AND product_id = ?', undef, - Bugzilla->user->id, $self->field->id, $self->name, $changes->{value}->[0], $changes->{value}->[0], $self->product_id - ); - # The milestone value is stored in the bugs table instead of its ID. - $dbh->do( - 'UPDATE bugs SET target_milestone = ?, lastdiffed = NOW() WHERE target_milestone = ? AND product_id = ?', - undef, $self->name, $changes->{value}->[0], $self->product_id - ); - # The default milestone also stores the value instead of the ID. - $dbh->do( - 'UPDATE products SET defaultmilestone = ? WHERE id = ? AND defaultmilestone = ?', - undef, $self->name, $self->product_id, $changes->{value}->[0] - ); - } - # Fill visibility values $self->set_visibility_values([ $self->product_id ]); @@ -162,36 +140,41 @@ sub update return $changes; } -sub remove_from_db { +sub remove_from_db +{ my $self = shift; my $dbh = Bugzilla->dbh; # The default milestone cannot be deleted. - if ($self->name eq $self->product->default_milestone) { + if ($self->id eq $self->product->default_milestone) + { ThrowUserError('milestone_is_default', { milestone => $self }); } - if ($self->bug_count) { + if ($self->bug_count) + { # We don't want to delete bugs when deleting a milestone. # Bugs concerned are reassigned to the default milestone. - my $bug_ids = - $dbh->selectcol_arrayref('SELECT bug_id FROM bugs - WHERE product_id = ? AND target_milestone = ?', - undef, ($self->product->id, $self->name)); + my $bug_ids = $dbh->selectcol_arrayref( + 'SELECT bug_id FROM bugs WHERE product_id = ? AND target_milestone = ?', + undef, ($self->product->id, $self->id) + ); my $timestamp = $dbh->selectrow_array('SELECT NOW()'); - $dbh->do('UPDATE bugs SET target_milestone = ?, delta_ts = ? - WHERE ' . $dbh->sql_in('bug_id', $bug_ids), - undef, ($self->product->default_milestone, $timestamp)); + $dbh->do( + 'UPDATE bugs SET target_milestone = ?, delta_ts = ? WHERE ' . $dbh->sql_in('bug_id', $bug_ids), + undef, ($self->product->default_milestone, $timestamp) + ); require Bugzilla::Bug; - import Bugzilla::Bug qw(LogActivityEntry); - foreach my $bug_id (@$bug_ids) { - LogActivityEntry($bug_id, 'target_milestone', - $self->name, - $self->product->default_milestone, - Bugzilla->user->id, $timestamp); + my $def = Bugzilla::Milestone->new($self->product->default_milestone); + foreach my $bug_id (@$bug_ids) + { + Bugzilla::Bug::LogActivityEntry( + $bug_id, 'target_milestone', $self->name, + $def && $def->name, Bugzilla->user->id, $timestamp + ); } } @@ -249,17 +232,19 @@ sub _check_product { sub set_name { $_[0]->set('value', $_[1]); } sub set_sortkey { $_[0]->set('sortkey', $_[1]); } -sub bug_count { +sub bug_count +{ my $self = shift; my $dbh = Bugzilla->dbh; - if (!defined $self->{'bug_count'}) { - $self->{'bug_count'} = $dbh->selectrow_array(q{ - SELECT COUNT(*) FROM bugs - WHERE product_id = ? AND target_milestone = ?}, - undef, $self->product_id, $self->name) || 0; + if (!defined $self->{bug_count}) + { + $self->{bug_count} = $dbh->selectrow_array( + "SELECT COUNT(*) FROM bugs WHERE product_id = ? AND target_milestone = ?", + undef, $self->product_id, $self->id + ) || 0; } - return $self->{'bug_count'}; + return $self->{bug_count}; } ################################ diff --git a/Bugzilla/Search/Quicksearch.pm b/Bugzilla/Search/Quicksearch.pm index 103d1b038..84e850187 100644 --- a/Bugzilla/Search/Quicksearch.pm +++ b/Bugzilla/Search/Quicksearch.pm @@ -1,5 +1,3 @@ -# -*- Mode: perl; indent-tabs-mode: nil -*- -# # The contents of this file are subject to the Mozilla Public # License Version 1.1 (the "License"); you may not use this file # except in compliance with the License. You may obtain a copy of @@ -17,6 +15,8 @@ # Andreas Franke # Stephen Lee # Marc Schumann +# +# Refactoring by Vitaliy Filippov package Bugzilla::Search::Quicksearch; diff --git a/Bugzilla/Status.pm b/Bugzilla/Status.pm index cf874ec3a..9cef8b3e5 100644 --- a/Bugzilla/Status.pm +++ b/Bugzilla/Status.pm @@ -45,10 +45,15 @@ use constant SPECIAL_STATUS_WORKFLOW_ACTIONS => qw( use constant DB_TABLE => 'bug_status'; use constant FIELD_NAME => 'bug_status'; -# This has all the standard Bugzilla::Field::Choice columns plus "is_open" +# This has all the standard Bugzilla::Field::Choice columns plus some new ones sub DB_COLUMNS { - return ($_[0]->SUPER::DB_COLUMNS, 'is_open'); + return ($_[0]->SUPER::DB_COLUMNS, qw(is_open is_assigned is_confirmed)); +} + +sub UPDATE_COLUMNS +{ + return ($_[0]->SUPER::UPDATE_COLUMNS, qw(is_open is_assigned is_confirmed)); } sub VALIDATORS @@ -56,6 +61,8 @@ sub VALIDATORS my $invocant = shift; my $validators = $invocant->SUPER::VALIDATORS; $validators->{is_open} = \&Bugzilla::Object::check_boolean; + $validators->{is_assigned} = \&Bugzilla::Object::check_boolean; + $validators->{is_confirmed} = \&Bugzilla::Object::check_boolean; $validators->{value} = \&_check_value; return $validators; } @@ -91,15 +98,13 @@ sub remove_from_db sub is_active { return $_[0]->{isactive}; } sub is_open { return $_[0]->{is_open}; } +sub is_assigned { return $_[0]->{is_assigned}; } +sub is_confirmed { return $_[0]->{is_confirmed}; } sub is_static { my $self = shift; - if ($self->name eq 'UNCONFIRMED' || $self->name eq Bugzilla->params->{duplicate_or_move_bug_status}) - { - return 1; - } - return 0; + return $self->name eq Bugzilla->params->{duplicate_or_move_bug_status} ? 1 : 0; } ############## diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm index 43fa95c45..2fefee3a6 100644 --- a/Bugzilla/Template.pm +++ b/Bugzilla/Template.pm @@ -936,8 +936,7 @@ sub create { 'user' => sub { return Bugzilla->user; }, # Currenly active language - # XXX Eventually this should probably be replaced with something - # like Bugzilla->language. + # FIXME Eventually this should probably be replaced with something like Bugzilla->language. 'current_language' => sub { my ($language) = include_languages(); return $language; diff --git a/Bugzilla/User.pm b/Bugzilla/User.pm index 73dac68e2..5d9a01316 100644 --- a/Bugzilla/User.pm +++ b/Bugzilla/User.pm @@ -1549,17 +1549,19 @@ sub wants_bug_mail { $wants_mail &= $self->wants_mail([EVT_CHANGED_BY_ME], $relationship); } - if ($wants_mail) { + if ($wants_mail) + { my $dbh = Bugzilla->dbh; # We don't create a Bug object from the bug_id here because we only # need one piece of information, and doing so (as of 2004-11-23) slows # down bugmail sending by a factor of 2. If Bug creation was more # lazy, this might not be so bad. - my $bug_status = $dbh->selectrow_array('SELECT bug_status - FROM bugs WHERE bug_id = ?', - undef, $bug_id); - - if ($bug_status eq "UNCONFIRMED") { + # FIXME: db abstraction?... or cache this value?... + my ($is_confirmed) = $dbh->selectrow_array( + 'SELECT bs.is_confirmed FROM bugs b, bug_status bs WHERE b.bug_id=? AND bs.id=b.bug_status', undef, $bug_id + ); + if (!$is_confirmed) + { $wants_mail &= $self->wants_mail([EVT_UNCONFIRMED], $relationship); } } diff --git a/Bugzilla/Version.pm b/Bugzilla/Version.pm index d4a035258..2e273ba7d 100644 --- a/Bugzilla/Version.pm +++ b/Bugzilla/Version.pm @@ -115,17 +115,18 @@ sub run_create_validators { return $params; } -sub bug_count { +sub bug_count +{ my $self = shift; my $dbh = Bugzilla->dbh; - - if (!defined $self->{'bug_count'}) { - $self->{'bug_count'} = $dbh->selectrow_array(qq{ - SELECT COUNT(*) FROM bugs - WHERE product_id = ? AND version = ?}, undef, - ($self->product_id, $self->name)) || 0; + if (!defined $self->{bug_count}) + { + $self->{bug_count} = $dbh->selectrow_array( + "SELECT COUNT(*) FROM bugs WHERE product_id = ? AND version = ?", + undef, ($self->product_id, $self->id) + ) || 0; } - return $self->{'bug_count'}; + return $self->{bug_count}; } sub create @@ -149,25 +150,8 @@ sub update my $dbh = Bugzilla->dbh; $dbh->bz_start_transaction(); - # Not Bugzilla::Field::Choice! It will overwrite other products' bug values my ($changes, $old_self) = Bugzilla::Object::update($self, @_); - if (exists $changes->{value}) - { - # Record activity - $self->field->{has_activity} = 1; - $dbh->do( - 'INSERT INTO bugs_activity (bug_id, who, bug_when, fieldid, added, removed)'. - ' SELECT bug_id, ?, NOW(), ?, ?, ? FROM bugs WHERE version = ? AND product_id = ?', undef, - Bugzilla->user->id, $self->field->id, $self->name, $old_self->name, $old_self->name, $self->product_id - ); - # Rename version - $dbh->do( - 'UPDATE bugs SET version = ?, lastdiffed = NOW() WHERE version = ? AND product_id = ?', - undef, $self->name, $old_self->name, $self->product_id - ); - } - # Fill visibility values $self->set_visibility_values([ $self->product_id ]); @@ -178,13 +162,13 @@ sub update return $changes; } -sub remove_from_db { +sub remove_from_db +{ my $self = shift; my $dbh = Bugzilla->dbh; - - # The version cannot be removed if there are bugs - # associated with it. - if ($self->bug_count) { + # The version cannot be removed if there are bugs associated with it. + if ($self->bug_count) + { ThrowUserError("version_has_bugs", { nb => $self->bug_count }); } # Remove visibility values diff --git a/buglist.cgi b/buglist.cgi index 8c9489c43..93c16513c 100755 --- a/buglist.cgi +++ b/buglist.cgi @@ -1184,7 +1184,9 @@ $vars->{columns} = $columns; $vars->{displaycolumns} = \@displaycolumns; $vars->{openstates} = [BUG_STATE_OPEN]; -$vars->{closedstates} = [map {$_->name} closed_bug_statuses()]; +# used by list.ics.tmpl +$vars->{assignedstates} = [ map { $_->name } grep { $_->is_active && $_->is_assigned } Bugzilla::Status->get_all ]; +$vars->{closedstates} = [ map { $_->name } closed_bug_statuses() ]; # The iCal file needs priorities ordered from 1 to 9 (highest to lowest) # If there are more than 9 values, just make all the lower ones 9 diff --git a/collectstats.pl b/collectstats.pl index a8001262f..e925f2a7c 100755 --- a/collectstats.pl +++ b/collectstats.pl @@ -118,9 +118,9 @@ my @resolutions = @{$fields->{'resolution'}}; my (%bug_status, %bug_resolution, %removed); if ($regenerate) { %bug_resolution = @{ $dbh->selectcol_arrayref( - 'SELECT bug_id, resolution FROM bugs', {Columns=>[1,2]}) }; + 'SELECT bug_id, resolution.value FROM bugs LEFT JOIN resolution ON resolution.id=bugs.resolution', {Columns=>[1,2]}) }; %bug_status = @{ $dbh->selectcol_arrayref( - 'SELECT bug_id, bug_status FROM bugs', {Columns=>[1,2]}) }; + 'SELECT bug_id, bug_status.value FROM bugs LEFT JOIN bug_status ON bug_status.id=bugs.bug_status', {Columns=>[1,2]}) }; my $removed_sth = $dbh->prepare( q{SELECT bugs_activity.bug_id, bugs_activity.removed,} @@ -209,8 +209,8 @@ sub collect_stats { # Now collect current data. my @row = (today()); - my $status_sql = q{SELECT COUNT(*) FROM bugs WHERE bug_status = ?}; - my $reso_sql = q{SELECT COUNT(*) FROM bugs WHERE resolution = ?}; + my $status_sql = q{SELECT COUNT(*) FROM bugs, bug_status WHERE bugs.bug_status=bug_status.id AND bug_status.value = ?}; + my $reso_sql = q{SELECT COUNT(*) FROM bugs, resolution WHERE bugs.resolution=resolution.id AND resolution.value = ?}; if ($product ne '-All-') { $status_sql .= q{ AND product_id = ?}; diff --git a/duplicates.cgi b/duplicates.cgi index db7d5a509..1227bb953 100755 --- a/duplicates.cgi +++ b/duplicates.cgi @@ -180,10 +180,11 @@ my %since_dups = @{$dbh->selectcol_arrayref( "SELECT dupe_of, COUNT(dupe) FROM duplicates INNER JOIN bugs_activity ON bugs_activity.bug_id = duplicates.dupe - WHERE added = 'DUPLICATE' AND fieldid = ? + WHERE added = ? AND fieldid = ? AND bug_when >= LOCALTIMESTAMP(0) - " . $dbh->sql_interval('?', 'DAY') . " GROUP BY dupe_of", {Columns=>[1,2]}, + Bugzilla->params->{duplicate_resolution}, $reso_field_id, $changedsince)}; add_indirect_dups(\%since_dups, \%dupe_relation); diff --git a/editproducts.cgi b/editproducts.cgi index 297e6c4f7..9ecc3e280 100755 --- a/editproducts.cgi +++ b/editproducts.cgi @@ -311,6 +311,7 @@ if ($action eq 'update') { $vars->{'classification'} = new Bugzilla::Classification($product->classification_id); } $vars->{'product'} = $product; + $vars->{unconfirmed_states} = [ map { $_->name } grep { !$_->is_confirmed } Bugzilla::Status->get_all ]; $vars->{'changes'} = $changes; $template->process("admin/products/updated.html.tmpl", $vars) diff --git a/editvalues.cgi b/editvalues.cgi index 13951b4b1..9485513da 100755 --- a/editvalues.cgi +++ b/editvalues.cgi @@ -212,20 +212,17 @@ if ($action eq 'update') { check_token_data($token, 'edit_field_value'); $vars->{value_old} = $value->name; - if ($value->can('set_timetracking')) + for ($value->UPDATE_COLUMNS) { - $value->set_timetracking($ARGS->{timetracking} ? 1 : 0); - } - $value->set_sortkey($ARGS->{sortkey}); - if (!($value->is_static || $value->is_default)) - { - $value->set_is_active($ARGS->{is_active}); - $value->set_name($ARGS->{value_new}); - if ($value->field->value_field) + if ($_ ne 'isactive' && $_ ne $value->NAME_FIELD || !$value->is_static && !$value->is_default) { - $vars->{changes}->{visibility_values} = $value->set_visibility_values($ARGS->{visibility_value_id}); + $value->set($_, $ARGS->{$_ eq $value->NAME_FIELD ? 'value_new' : $_}); } } + if (!($value->is_static || $value->is_default) && $value->field->value_field) + { + $vars->{changes}->{visibility_values} = $value->set_visibility_values($ARGS->{visibility_value_id}); + } delete_token($token); $vars->{changes} = $value->update; $vars->{message} = 'field_value_updated'; diff --git a/editworkflow.cgi b/editworkflow.cgi index b9c54d126..d66669534 100755 --- a/editworkflow.cgi +++ b/editworkflow.cgi @@ -85,7 +85,7 @@ elsif ($action eq 'update') { # Part 1: Initial bug statuses. foreach my $new (@$statuses) { - if (($new->is_open || $new->name eq 'RESOLVED') && $cgi->param('w_0_' . $new->id)) { + if (($new->is_open || $new->name eq Bugzilla->params->{duplicate_or_move_bug_status}) && $cgi->param('w_0_' . $new->id)) { $sth_insert->execute(undef, $new->id) unless defined $workflow->{0}->{$new->id}; } diff --git a/enter_bug.cgi b/enter_bug.cgi index 201d52f71..51c86c9b0 100755 --- a/enter_bug.cgi +++ b/enter_bug.cgi @@ -645,12 +645,12 @@ my $initial_statuses = Bugzilla::Status->can_change_to(); # Exclude closed states from the UI, even if the workflow allows them. # The back-end code will still accept them, though. -@$initial_statuses = grep { $_->name eq 'RESOLVED' || $_->is_open } @$initial_statuses; +@$initial_statuses = grep { $_->name eq Bugzilla->params->{duplicate_or_move_bug_status} || $_->is_open } @$initial_statuses; if (!$product->allows_unconfirmed) { # UNCONFIRMED is illegal if allows_unconfirmed is false. - @$initial_statuses = grep { $_->name ne 'UNCONFIRMED' } @$initial_statuses; + @$initial_statuses = grep { $_->is_confirmed } @$initial_statuses; } scalar(@$initial_statuses) || ThrowUserError('no_initial_bug_status'); @@ -658,7 +658,8 @@ scalar(@$initial_statuses) || ThrowUserError('no_initial_bug_status'); unless ($has_editbugs || $has_canconfirm) { # ... use UNCONFIRMED if available, else use the first status of the list. - my $bug_status = (grep { $_->name eq 'UNCONFIRMED' } @$initial_statuses) ? 'UNCONFIRMED' : $initial_statuses->[0]; + my ($bug_status) = grep { !$_->is_confirmed } @$initial_statuses; + $bug_status ||= $initial_statuses->[0]; @$initial_statuses = ($bug_status); } diff --git a/importxml.pl b/importxml.pl index d0f0d78ae..0657d4028 100755 --- a/importxml.pl +++ b/importxml.pl @@ -919,7 +919,7 @@ sub process_bug { # entry in the dup table. Since we can't tell the bug ID of bugs # that might not yet be in the database we have no way of populating # this table. Change the resolution instead. - if ( $valid_res && ( $bug_fields{'resolution'} eq "DUPLICATE" ) ) { + if ( $valid_res && ( $bug_fields{'resolution'} eq 'DUPLICATE' ) ) { $resolution = "MOVED"; $err .= "This bug was marked DUPLICATE in the database "; $err .= "it was moved from.\n Changing resolution to \"MOVED\"\n"; @@ -928,7 +928,7 @@ sub process_bug { # If there is at least 1 initial bug status different from UNCO, use it, # else use the open bug status with the lowest sortkey (different from UNCO). my @bug_statuses = @{Bugzilla::Status->can_change_to()}; - @bug_statuses = grep { $_->name ne 'UNCONFIRMED' } @bug_statuses; + @bug_statuses = grep { $_->is_confirmed } @bug_statuses; my $initial_status; if (scalar(@bug_statuses)) { @@ -937,7 +937,7 @@ sub process_bug { else { @bug_statuses = Bugzilla::Status->get_all(); # Exclude UNCO and inactive bug statuses. - @bug_statuses = grep { $_->is_active && $_->name ne 'UNCONFIRMED'} @bug_statuses; + @bug_statuses = grep { $_->is_active && $_->is_confirmed } @bug_statuses; my @open_statuses = grep { $_->is_open } @bug_statuses; if (scalar(@open_statuses)) { $initial_status = $open_statuses[0]->name; @@ -961,6 +961,7 @@ sub process_bug { $status = $initial_status; } else{ + # FIXME Remove bug_status==UNCONFIRMED hardcode $status = "UNCONFIRMED"; } if ($status ne $bug_fields{'bug_status'}){ @@ -970,6 +971,7 @@ sub process_bug { } } if($everconfirmed){ + # FIXME Remove bug_status==UNCONFIRMED hardcode if($status eq "UNCONFIRMED"){ $err .= "Bug Status was UNCONFIRMED but everconfirmed was true\n"; $err .= " Setting status to $initial_status\n"; @@ -978,6 +980,7 @@ sub process_bug { } } else{ # $everconfirmed is false + # FIXME Remove bug_status==UNCONFIRMED hardcode if($status ne "UNCONFIRMED"){ $err .= "Bug Status was $status but everconfirmed was false\n"; $err .= " Setting status to UNCONFIRMED\n"; diff --git a/sanitycheck.cgi b/sanitycheck.cgi index 73df4d991..f12bc25b7 100755 --- a/sanitycheck.cgi +++ b/sanitycheck.cgi @@ -226,6 +226,7 @@ if ($cgi->param('repair_creation_date')) { if ($cgi->param('repair_everconfirmed')) { Status('everconfirmed_start'); + # FIXME Remove bug_status==UNCONFIRMED hardcode my @confirmed_open_states = grep {$_ ne 'UNCONFIRMED'} BUG_STATE_OPEN; my $confirmed_open_states = join(', ', map {$dbh->quote($_)} @confirmed_open_states); diff --git a/showdependencygraph.cgi b/showdependencygraph.cgi index 7510e1cfe..23c40ed1b 100755 --- a/showdependencygraph.cgi +++ b/showdependencygraph.cgi @@ -1,25 +1,7 @@ #!/usr/bin/perl -wT -# -*- Mode: perl; indent-tabs-mode: nil -*- -# -# The contents of this file are subject to the Mozilla Public -# License Version 1.1 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS -# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is the Bugzilla Bug Tracking System. -# -# The Initial Developer of the Original Code is Netscape Communications -# Corporation. Portions created by Netscape are -# Copyright (C) 1998 Netscape Communications Corporation. All -# Rights Reserved. -# -# Contributor(s): Terry Weissman -# Gervase Markham +# (Rewritten) Bug dependency graph display +# License: Dual-license GPL 3.0+ or MPL 1.1+ +# Author(s): Vitaliy Filippov use utf8; use strict; @@ -44,7 +26,8 @@ my $vars = {}; # Check params my $display = $cgi->param('display') || 'tree'; -if (!defined $cgi->param('id') && $display ne 'doall') { +if (!defined $cgi->param('id') && $display ne 'doall') +{ ThrowCodeError("missing_bug_id"); } @@ -376,24 +359,28 @@ sub GetNodes my $nodes = {}; my $bugtitles = {}; # Retrieve bug information from the database + # FIXME: Use Bugzilla::Search for this query my $rows = Bugzilla->dbh->selectall_arrayref( "SELECT t1.bug_id, - t1.bug_status, - t1.resolution, + bs.value bug_status, + res.value resolution, t1.short_desc, t1.estimated_time, SUM(t3.work_time) AS work_time, t1.assigned_to, t2.login_name AS assigned_to_login, - t4.name AS product, - t5.name AS component, - t1.bug_severity + p.name AS product, + c.name AS component, + sev.value bug_severity FROM bugs AS t1 +LEFT JOIN bug_status AS bs ON bs.id=t1.bug_status +LEFT JOIN resolution AS res ON res.id=t1.resolution +LEFT JOIN bug_severity AS sev ON sev.id=t1.bug_severity LEFT JOIN profiles AS t2 ON t2.userid=t1.assigned_to LEFT JOIN longdescs AS t3 ON t3.bug_id=t1.bug_id AND t3.work_time > 0 -LEFT JOIN products AS t4 ON t4.id=t1.product_id -LEFT JOIN components AS t5 ON t5.id=t1.component_id +LEFT JOIN products AS p ON p.id=t1.product_id +LEFT JOIN components AS c ON c.id=t1.component_id WHERE t1.bug_id IN (".join(",", ("?") x scalar keys %$seen).") GROUP BY t1.bug_id", {Slice=>{}}, keys %$seen) || {}; foreach my $row (@$rows) @@ -523,7 +510,8 @@ sub CleanupOldDots # symlinks), this can't escape to delete anything it shouldn't # (unless someone moves the location of $webdotdir, of course) trick_taint($f); - if (file_mod_time($f) < $since) { + if (file_mod_time($f) < $since) + { unlink $f; } } @@ -533,6 +521,7 @@ sub GetColorByState { my ($state, $base) = (@_); $base = $base ? 0 : 0x40; + # FIXME Remove bug_status hardcode my %colorbystate = ( UNCONFIRMED => 'ffffff', NEW => 'ff8000', diff --git a/skins/standard/buglist.css b/skins/standard/buglist.css index 1fde1ed62..159758e95 100644 --- a/skins/standard/buglist.css +++ b/skins/standard/buglist.css @@ -94,6 +94,7 @@ td.bz_total { .bz_buglist .bz_dependson_column { width: 8%; white-space: normal; } /* Bug states - duplicated here for external stylesheet usage */ +/* FIXME: remove bug_status hardcode */ .bz_st_UNCONFIRMED, .bz_UNCONFIRMED td.first-child a { font-style: italic; } .bz_st_RESOLVED, .bz_RESOLVED td.first-child a { text-decoration: line-through; } .bz_st_VERIFIED, .bz_VERIFIED td.first-child a { text-decoration: line-through; border: 1px dashed #2f6fab; margin: 0 -1px; color: black; background-color: #f9f9f9; line-height: 1.1em; } diff --git a/skins/standard/global.css b/skins/standard/global.css index 4fd956fb0..ca386d744 100644 --- a/skins/standard/global.css +++ b/skins/standard/global.css @@ -504,6 +504,7 @@ form#Create .comment { } /* Bug states */ +/* FIXME remove bug_status hardcode */ .bz_st_UNCONFIRMED, .bz_UNCONFIRMED td.first-child a { font-style: italic; } .bz_st_RESOLVED, .bz_RESOLVED td.first-child a { text-decoration: line-through; } .bz_st_VERIFIED, .bz_VERIFIED td.first-child a { text-decoration: line-through; border: 1px dashed #2f6fab; margin: 0 -1px; color: black; background-color: #f9f9f9; line-height: 1.1em; } diff --git a/template/en/default/account/prefs/email.html.tmpl b/template/en/default/account/prefs/email.html.tmpl index e60ef5502..2bad7c68f 100644 --- a/template/en/default/account/prefs/email.html.tmpl +++ b/template/en/default/account/prefs/email.html.tmpl @@ -142,7 +142,7 @@ document.write(' - + @@ -46,19 +46,33 @@ - + [% IF field.name == "bug_status" %] - + [% IF value.is_open %]Open[% ELSE %]Closed[% END %] + + + + + + + + + + + + [% END %] [% IF field.value_field && !value.is_static %] - + Only appears when [%+ field.value_field.description FILTER html %] is set to: @@ -79,10 +93,10 @@ [% END %] - + - [% IF value.is_default %] This value is selected as default in the parameters for this field. It cannot be disabled. diff --git a/template/en/default/admin/products/edit-common.html.tmpl b/template/en/default/admin/products/edit-common.html.tmpl index ba5125dcb..a93fbf1a2 100644 --- a/template/en/default/admin/products/edit-common.html.tmpl +++ b/template/en/default/admin/products/edit-common.html.tmpl @@ -49,9 +49,8 @@ - + [% IF product.allows_unconfirmed %] - The product now allows the - UNCONFIRMED status. + The product now allows unconfirmed states. [% ELSE %] - The product no longer allows the - UNCONFIRMED status. + The product no longer allows unconfirmed states. Note that any - - [%- terms.bugs %] that currently have the - UNCONFIRMED status + + [%- terms.bugs %] that currently have unconfirmed states + will remain in that status until they are edited. [% END %]

diff --git a/template/en/default/admin/workflow/edit.html.tmpl b/template/en/default/admin/workflow/edit.html.tmpl index 7a39c4ab1..6cb1d4264 100644 --- a/template/en/default/admin/workflow/edit.html.tmpl +++ b/template/en/default/admin/workflow/edit.html.tmpl @@ -30,6 +30,7 @@ //--> +[%# FIXME Check if this is correct about 'one of either UNCONFIRMED or REOPENED' %]

This page allows you to define which status transitions are valid in your workflow. For compatibility with older versions of [% terms.Bugzilla %], reopening [% terms.abug %] @@ -66,7 +67,7 @@ [% FOREACH new_status = statuses %] - [% IF status.id != new_status.id && (status.id || new_status.name == 'RESOLVED' || new_status.is_open) %] + [% IF status.id != new_status.id && (status.id || new_status.name == Param('duplicate_or_move_bug_status') || new_status.is_open) %] [% checked = workflow.${status.id}.${new_status.id}.defined ? 1 : 0 %] [% mandatory = (status.id && new_status.name == Param("duplicate_or_move_bug_status")) ? 1 : 0 %] [% END %] - [% bug_statuses = [] %] - [% FOREACH bug_status = bug.status.can_change_to %] - [% NEXT IF bug_status.name == "UNCONFIRMED" && !bug.product_obj.allows_unconfirmed %] - [% bug_statuses.push(bug_status) %] - [% END %] + [% bug_statuses = bug.statuses_available %] [% IF bug_statuses.size %] @@ -95,7 +91,7 @@ [% END %] [% IF bug.resolution OR bug.check_can_change_field('resolution', bug.resolution, 1) %] - + [% END %] @@ -107,12 +103,14 @@ %]