]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 169752: Activity log should fuse data fields split because they didn't fit
authorFrédéric Buclin <LpSolit@gmail.com>
Wed, 14 Dec 2011 13:20:17 +0000 (14:20 +0100)
committerFrédéric Buclin <LpSolit@gmail.com>
Wed, 14 Dec 2011 13:20:17 +0000 (14:20 +0100)
r=glob a=LpSolit

Bugzilla/Bug.pm
Bugzilla/WebService/Bug.pm
attachment.cgi
process_bug.cgi
show_activity.cgi

index d49a4dc26b375e2cd8e8b9828a929174dbff87ef..5e54318fb8b9bb4462f854b4dc29436784aefdf2 100644 (file)
@@ -3754,12 +3754,13 @@ sub _bugs_in_order {
 
 # Get the activity of a bug, starting from $starttime (if given).
 # This routine assumes Bugzilla::Bug->check has been previously called.
-sub GetBugActivity {
-    my ($bug_id, $attach_id, $starttime) = @_;
+sub get_activity {
+    my ($self, $attach_id, $starttime) = @_;
     my $dbh = Bugzilla->dbh;
+    my $user = Bugzilla->user;
 
     # Arguments passed to the SQL query.
-    my @args = ($bug_id);
+    my @args = ($self->id);
 
     # Only consider changes since $starttime, if given.
     my $datepart = "";
@@ -3778,8 +3779,7 @@ sub GetBugActivity {
     # Only includes attachments the user is allowed to see.
     my $suppjoins = "";
     my $suppwhere = "";
-    if (!Bugzilla->user->is_insider) 
-    {
+    if (!$user->is_insider) {
         $suppjoins = "LEFT JOIN attachments 
                    ON attachments.attach_id = bugs_activity.attach_id";
         $suppwhere = "AND COALESCE(attachments.isprivate, 0) = 0";
@@ -3814,16 +3814,11 @@ sub GetBugActivity {
         my $activity_visible = 1;
 
         # check if the user should see this field's activity
-        if ($fieldname eq 'remaining_time'
-            || $fieldname eq 'estimated_time'
-            || $fieldname eq 'work_time'
-            || $fieldname eq 'deadline')
-        {
-            $activity_visible = Bugzilla->user->is_timetracker;
+        if (grep { $fieldname eq $_ } TIMETRACKING_FIELDS) {
+            $activity_visible = $user->is_timetracker;
         }
         elsif ($fieldname eq 'longdescs.isprivate'
-                && !Bugzilla->user->is_insider 
-                && $added) 
+               && !$user->is_insider && $added)
         { 
             $activity_visible = 0;
         } 
@@ -3854,14 +3849,24 @@ sub GetBugActivity {
                 $changes = [];
             }
 
+            # If this is the same field as the previous item, then concatenate
+            # the data into the same change.
+            if ($operation->{'who'} && $who eq $operation->{'who'}
+                && $when eq $operation->{'when'}
+                && $fieldname eq $operation->{'fieldname'}
+                && ($attachid || 0) == ($operation->{'attachid'} || 0))
+            {
+                my $old_change = pop @$changes;
+                $removed = $old_change->{'removed'} . $removed;
+                $added = $old_change->{'added'} . $added;
+            }
             $operation->{'who'} = $who;
             $operation->{'when'} = $when;
-
-            $change{'fieldname'} = $fieldname;
-            $change{'attachid'} = $attachid;
+            $operation->{'fieldname'} = $change{'fieldname'} = $fieldname;
+            $operation->{'attachid'} = $change{'attachid'} = $attachid;
             $change{'removed'} = $removed;
             $change{'added'} = $added;
-            
+
             if ($comment_id) {
                 $change{'comment'} = Bugzilla::Comment->new($comment_id);
             }
index eece1af6c674a92745061ca3da0ed1edeca070d5..b0f8c0a0cd147bd44e99d12adf1f90dd033aa761 100644 (file)
@@ -355,7 +355,7 @@ sub history {
         $bug_id = $bug->id;
         $item{id} = $self->type('int', $bug_id);
 
-        my ($activity) = Bugzilla::Bug::GetBugActivity($bug_id);
+        my ($activity) = $bug->get_activity;
 
         my @history;
         foreach my $changeset (@$activity) {
index 504ade424d1b2f953380588b1a9698b3cbb083ae..b577f74159280f44d227bd569132c662acb7969d 100755 (executable)
@@ -676,8 +676,7 @@ sub update {
         if (defined $cgi->param('delta_ts')
             && $cgi->param('delta_ts') ne $attachment->modification_time)
         {
-            ($vars->{'operations'}) =
-                Bugzilla::Bug::GetBugActivity($bug->id, $attachment->id, $cgi->param('delta_ts'));
+            ($vars->{'operations'}) = $bug->get_activity($attachment->id, $cgi->param('delta_ts'));
 
             # The token contains the old modification_time. We need a new one.
             $cgi->param('token', issue_hash_token([$attachment->id, $attachment->modification_time]));
index bf18a45d30805b60686ca3472acb965f273422b2..2d04f73c17120f8f90ab94b3816b0e8ed83e2bca 100755 (executable)
@@ -143,9 +143,7 @@ if (defined $cgi->param('delta_ts'))
     my $delta_ts_z = datetime_from($cgi->param('delta_ts'));
     my $first_delta_tz_z =  datetime_from($first_bug->delta_ts);
     if ($first_delta_tz_z ne $delta_ts_z) {
-        ($vars->{'operations'}) =
-            Bugzilla::Bug::GetBugActivity($first_bug->id, undef,
-                                          scalar $cgi->param('delta_ts'));
+        ($vars->{'operations'}) = $first_bug->get_activity(undef, $cgi->param('delta_ts'));
 
         $vars->{'title_tag'} = "mid_air";
     
index 27096018fcdbe628c3c61e99200cad7f8d439c9e..651c34ed313d26427ef73254b3de6e867dd842f9 100755 (executable)
@@ -54,8 +54,7 @@ my $bug = Bugzilla::Bug->check($id);
 # visible immediately due to replication lag.
 Bugzilla->switch_to_shadow_db;
 
-($vars->{'operations'}, $vars->{'incomplete_data'}) = 
-    Bugzilla::Bug::GetBugActivity($bug->id);
+($vars->{'operations'}, $vars->{'incomplete_data'}) = $bug->get_activity;
 
 $vars->{'bug'} = $bug;