]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 345100: Remove obsolete parameters and "officially" turn on custom bug status...
authorlpsolit%gmail.com <>
Thu, 14 Jun 2007 21:30:30 +0000 (21:30 +0000)
committerlpsolit%gmail.com <>
Thu, 14 Jun 2007 21:30:30 +0000 (21:30 +0000)
Bugzilla/Bug.pm
Bugzilla/Config.pm
Bugzilla/Config/BugChange.pm
Bugzilla/Install/DB.pm
checksetup.pl
sanitycheck.cgi
template/en/default/admin/admin.html.tmpl
template/en/default/admin/params/bugchange.html.tmpl

index 5ca806092961c68032f3da2556c7e4f48e4c998f..c3be53e9615e2434a1f7b9f19c3bf2d05f8c0a6b 100755 (executable)
@@ -378,6 +378,11 @@ sub run_create_validators {
     ($params->{bug_status}, $params->{everconfirmed})
         = $class->_check_bug_status($params->{bug_status}, $product);
 
+    # Check whether a comment is required on bug creation.
+    my $vars = {};
+    $vars->{comment_exists} = ($params->{comment} =~ /\S+/) ? 1 : 0;
+    Bugzilla::Bug->check_status_change_triggers($params->{bug_status}, [], $vars);
+
     $params->{target_milestone} = $class->_check_target_milestone($product,
         $params->{target_milestone});
 
@@ -653,10 +658,6 @@ sub _check_comment {
 
     # Creation-only checks
     if (!ref $invocant) {
-        if (Bugzilla->params->{"commentoncreate"} && !$comment) {
-            ThrowUserError("description_required");
-        }
-
         # On creation only, there must be a single-space comment, or
         # email will be supressed.
         $comment = ' ' if $comment eq '';
@@ -1588,6 +1589,19 @@ sub check_status_change_triggers {
             # 'commentonnone' doesn't exist, so this is safe.
             ThrowUserError('comment_required') if Bugzilla->params->{"commenton$action"};
         }
+        elsif (!scalar(@$bug_ids)) {
+            # The bug is being created; that's why $bug_ids is undefined.
+            my $comment_required =
+              $dbh->selectrow_array('SELECT require_comment
+                                       FROM status_workflow
+                                 INNER JOIN bug_status
+                                         ON id = new_status
+                                      WHERE old_status IS NULL
+                                        AND value = ?',
+                                      undef, $action);
+
+            ThrowUserError('description_required') if $comment_required;
+        }
         else {
             my $required_for_transitions =
               $dbh->selectcol_arrayref('SELECT DISTINCT bug_status.value
@@ -1614,6 +1628,10 @@ sub check_status_change_triggers {
     # There is no checks for these actions.
     return if ($action eq 'none' || $action eq 'clearresolution');
 
+    # Also leave now if we are creating a new bug (we only want to check
+    # if a comment is required on bug creation).
+    return unless scalar(@$bug_ids);
+
     if ($action eq 'duplicate') {
         # You cannot mark bugs as duplicates when changing
         # several bugs at once.
index 85c9d6decbe6514582c072a2f895e2396136a471..fe58e02822b10ed30b9f420366c369cc5ac85680 100644 (file)
@@ -199,18 +199,16 @@ sub update_params {
 
     # --- REMOVE OLD PARAMS ---
 
-    my @oldparams;
+    my %oldparams;
     # Remove any old params, put them in old-params.txt
     foreach my $item (keys %$param) {
         if (!grep($_ eq $item, map ($_->{'name'}, @param_list))) {
-            local $Data::Dumper::Terse  = 1;
-            local $Data::Dumper::Indent = 0;
-            push (@oldparams, [$item, Data::Dumper->Dump([$param->{$item}])]);
+            $oldparams{$item} = $param->{$item};
             delete $param->{$item};
         }
     }
 
-    if (@oldparams) {
+    if (scalar(keys %oldparams)) {
         my $op_file = new IO::File('old-params.txt', '>>', 0600)
           || die "old-params.txt: $!";
 
@@ -218,11 +216,14 @@ sub update_params {
               " and so have been\nmoved from your parameters file into",
               " old-params.txt:\n";
 
-        foreach my $p (@oldparams) {
-            my ($item, $value) = @$p;
-            print $op_file "\n\n$item:\n$value\n";
-            print $item;
-            print ", " unless $item eq $oldparams[$#oldparams]->[0];
+        local $Data::Dumper::Terse  = 1;
+        local $Data::Dumper::Indent = 0;
+
+        my $comma = "";
+        foreach my $item (keys %oldparams) {
+            print $op_file "\n\n$item:\n" . Data::Dumper->Dump([$oldparams{$item}]) . "\n";
+            print "${comma}$item";
+            $comma = ", ";
         }
         print "\n";
         $op_file->close;
@@ -250,6 +251,10 @@ sub update_params {
     }
 
     write_params($param);
+
+    # Return deleted params and values so that checksetup.pl has a chance
+    # to convert old params to new data.
+    return %oldparams;
 }
 
 sub write_params {
index bacacc082d0c7a41b1e9c6312a44a0d3d64f800c..6941f00469336264dedc5348f33d5eb873cb3c47 100644 (file)
@@ -58,18 +58,6 @@ sub get_param_list {
    default => 0
   },
 
-  {
-   name => 'commentoncreate',
-   type => 'b',
-   default => 0
-  },
-
-  {
-   name => 'commentonaccept',
-   type => 'b',
-   default => 0
-  },
-
   {
    name => 'commentonclearresolution',
    type => 'b',
@@ -77,19 +65,7 @@ sub get_param_list {
   },
 
   {
-   name => 'commentonconfirm',
-   type => 'b',
-   default => 0
-  },
-
-  {
-   name => 'commentonresolve',
-   type => 'b',
-   default => 0
-  },
-
-  {
-   name => 'commentonreassign',
+   name => 'commentonchange_resolution',
    type => 'b',
    default => 0
   },
@@ -100,24 +76,6 @@ sub get_param_list {
    default => 0
   },
 
-  {
-   name => 'commentonreopen',
-   type => 'b',
-   default => 0
-  },
-
-  {
-   name => 'commentonverify',
-   type => 'b',
-   default => 0
-  },
-
-  {
-   name => 'commentonclose',
-   type => 'b',
-   default => 0
-  },
-
   {
    name => 'commentonduplicate',
    type => 'b',
index 7dd5ad26963941aaf1a988482896ed63099b0a80..3991cd453e182ec04ef04dc4f49cf9dab4e772e6 100644 (file)
@@ -115,6 +115,7 @@ sub update_fielddefs_definition {
 # the purpose of a column.
 #
 sub update_table_definitions {
+    my $old_params = shift;
     my $dbh = Bugzilla->dbh;
     _update_pre_checksetup_bugzillas();
 
@@ -507,7 +508,7 @@ sub update_table_definitions {
     _fix_uppercase_index_names();
 
     # 2007-05-17 LpSolit@gmail.com - Bug 344965
-    _initialize_workflow();
+    _initialize_workflow($old_params);
 
     ################################################################
     # New --TABLE-- changes should go *** A B O V E *** this point #
@@ -2779,6 +2780,7 @@ sub _fix_uppercase_index_names {
 }
 
 sub _initialize_workflow {
+    my $old_params = shift;
     my $dbh = Bugzilla->dbh;
 
     if (!$dbh->bz_column_info('bug_status', 'is_open')) {
@@ -2809,16 +2811,16 @@ sub _initialize_workflow {
     my $count = $dbh->selectrow_array('SELECT COUNT(*) FROM status_workflow');
     return if $count;
 
-    my $create = Bugzilla->params->{'commentoncreate'};
-    my $confirm = Bugzilla->params->{'commentonconfirm'};
-    my $accept = Bugzilla->params->{'commentonaccept'};
-    my $resolve = Bugzilla->params->{'commentonresolve'};
-    my $verify = Bugzilla->params->{'commentonverify'};
-    my $close = Bugzilla->params->{'commentonclose'};
-    my $reopen = Bugzilla->params->{'commentonreopen'};
+    my $create = $old_params->{'commentoncreate'};
+    my $confirm = $old_params->{'commentonconfirm'};
+    my $accept = $old_params->{'commentonaccept'};
+    my $resolve = $old_params->{'commentonresolve'};
+    my $verify = $old_params->{'commentonverify'};
+    my $close = $old_params->{'commentonclose'};
+    my $reopen = $old_params->{'commentonreopen'};
     # This was till recently the only way to get back to NEW for
     # confirmed bugs, so we use this parameter here.
-    my $reassign = Bugzilla->params->{'commentonreassign'};
+    my $reassign = $old_params->{'commentonreassign'};
 
     # This is the default workflow.
     my @workflow = ([undef, 'UNCONFIRMED', $create],
index 81eab9b8761bd60bb1bcdc7818d175c0e1a6cdb4..6d2037b9e1fedeec72045e9937db513bcc4cb8e5 100755 (executable)
@@ -155,7 +155,7 @@ create_htaccess() if $lc_hash->{'create_htaccess'};
 
 # Remove parameters from the params file that no longer exist in Bugzilla,
 # and set the defaults for new ones
-update_params();
+my %old_params = update_params();
 
 ###########################################################################
 # Pre-compile --TEMPLATE-- code
@@ -193,7 +193,7 @@ Bugzilla::Field::populate_field_definitions();
 # Update the tables to the current definition --TABLE--
 ###########################################################################
 
-Bugzilla::Install::DB::update_table_definitions();        
+Bugzilla::Install::DB::update_table_definitions(\%old_params);
 
 ###########################################################################
 # Bugzilla uses --GROUPS-- to assign various rights to its users.
index c1444ac82bb24059f1a4d636178befad872f8703..ab44a3a79eb8b8fe336761b60c5d568abf43152b 100755 (executable)
@@ -201,7 +201,7 @@ if ($cgi->param('repair_creation_date')) {
                                         WHERE bug_id = ?');
 
     # All bugs have an entry in the 'longdescs' table when they are created,
-    # even if 'commentoncreate' is turned off.
+    # even if no comment is required.
     my $sth_getDate = $dbh->prepare('SELECT MIN(bug_when) FROM longdescs
                                      WHERE bug_id = ?');
 
index 15316ed6479865b0de3ad2ebb45b2af462ef4ec0..0555cf0f571a40b57f99c0d683d6f6e2e5065a3c 100644 (file)
         can also edit some specific attributes of products such as
         <a href="editcomponents.cgi">components</a>, <a href="editversions.cgi">versions</a>
         and <a href="editmilestones.cgi">milestones</a> directly.</dd>
-      </dl>
-    </td>
 
-    <td class="admin_links">
-      <dl>
         [% class = user.groups.editcomponents ? "" : "forbidden" %]
         <dt class="[% class %]"><a href="editflagtypes.cgi">Flags</a></dt>
         <dd class="[% class %]">A flag is a custom 4-states attribute of [% terms.bugs %]
         and/or attachments. These states are: granted, denied, requested and undefined.
         You can set as many flags as desired per [% terms.bug %], and define which users
         are allowed to edit them.</dd>
+      </dl>
+    </td>
 
+    <td class="admin_links">
+      <dl>
         [% class = user.groups.admin ? "" : "forbidden" %]
         <dt class="[% class %]"><a href="editfields.cgi">Custom Fields</a></dt>
         <dd class="[% class %]">[% terms.Bugzilla %] lets you define fields which are
         to some given list. This is also the place where you define legal values for some
         types of custom fields.</dd>
 
+        <dt class="[% class %]"><a href="editworkflow.cgi">[%terms.Bug %] Status Workflow</a></dt>
+        <dd class="[% class %]">Customize your workflow and choose initial [% terms.bug %]
+        statuses available on [% terms.bug %] creation and allowed [% terms.bug %] status
+        transitions when editing existing [% terms.bugs %].</dd>
+
         [% class = user.groups.creategroups ? "" : "forbidden" %]
         <dt class="[% class %]"><a href="editgroups.cgi">Groups</a></dt>
         <dd class="[% class %]">Define groups which will be used in the installation.
index b9475d41c9d761b4cca7c37009d83b106ba481cb..022e0cac11493bfbf58b67d8f47a922047ce36bb 100644 (file)
   musthavemilestoneonaccept => "If you are using Target Milestone, do you want to require that " _
                                "the milestone be set in order for a user to ACCEPT a ${terms.bug}?",
 
-  commentoncreate => "If this option is on, the user needs to enter a description " _
-                     "when entering a new ${terms.bug}.",
-
-  commentonaccept => "If this option is on, the user needs to enter a short comment if " _
-                     "he accepts the ${terms.bug}.",
-
   commentonclearresolution => "If this option is on, the user needs to enter a short comment if " _
                               "the ${terms.bug}'s resolution is cleared.",
 
-  commentonconfirm => "If this option is on, the user needs to enter a short comment " _
-                      "when confirming a ${terms.bug}.",
-
-  commentonresolve => "If this option is on, the user needs to enter a short comment if " _
-                      "the $terms.bug is resolved.",
-
-  commentonreassign => "If this option is on, the user needs to enter a short comment if " _
-                       "the $terms.bug is reassigned.",
+  commentonchange_resolution => "If this option is on, the user needs to enter a short " _
+                                "comment if the resolution of the $terms.bug changes.",
 
   commentonreassignbycomponent => "If this option is on, the user needs to enter a short comment if " _
                                   "the $terms.bug is reassigned by component.",
 
-  commentonreopen => "If this option is on, the user needs to enter a short comment if " _
-                     "the $terms.bug is reopened.",
-
-  commentonverify => "If this option is on, the user needs to enter a short comment if " _
-                     "the $terms.bug is verified.",
-
-  commentonclose => "If this option is on, the user needs to enter a short comment if " _
-                    "the $terms.bug is closed.",
-
   commentonduplicate => "If this option is on, the user needs to enter a short comment " _
                         "if the $terms.bug is marked as duplicate.",