Commit c5d33db7 authored by Frédéric Buclin's avatar Frédéric Buclin

Bug 169752: Activity log should fuse data fields split because they didn't fit

r=glob a=LpSolit
parent cc86e1bc
...@@ -3754,12 +3754,13 @@ sub _bugs_in_order { ...@@ -3754,12 +3754,13 @@ sub _bugs_in_order {
# Get the activity of a bug, starting from $starttime (if given). # Get the activity of a bug, starting from $starttime (if given).
# This routine assumes Bugzilla::Bug->check has been previously called. # This routine assumes Bugzilla::Bug->check has been previously called.
sub GetBugActivity { sub get_activity {
my ($bug_id, $attach_id, $starttime) = @_; my ($self, $attach_id, $starttime) = @_;
my $dbh = Bugzilla->dbh; my $dbh = Bugzilla->dbh;
my $user = Bugzilla->user;
# Arguments passed to the SQL query. # Arguments passed to the SQL query.
my @args = ($bug_id); my @args = ($self->id);
# Only consider changes since $starttime, if given. # Only consider changes since $starttime, if given.
my $datepart = ""; my $datepart = "";
...@@ -3778,8 +3779,7 @@ sub GetBugActivity { ...@@ -3778,8 +3779,7 @@ sub GetBugActivity {
# Only includes attachments the user is allowed to see. # Only includes attachments the user is allowed to see.
my $suppjoins = ""; my $suppjoins = "";
my $suppwhere = ""; my $suppwhere = "";
if (!Bugzilla->user->is_insider) if (!$user->is_insider) {
{
$suppjoins = "LEFT JOIN attachments $suppjoins = "LEFT JOIN attachments
ON attachments.attach_id = bugs_activity.attach_id"; ON attachments.attach_id = bugs_activity.attach_id";
$suppwhere = "AND COALESCE(attachments.isprivate, 0) = 0"; $suppwhere = "AND COALESCE(attachments.isprivate, 0) = 0";
...@@ -3814,16 +3814,11 @@ sub GetBugActivity { ...@@ -3814,16 +3814,11 @@ sub GetBugActivity {
my $activity_visible = 1; my $activity_visible = 1;
# check if the user should see this field's activity # check if the user should see this field's activity
if ($fieldname eq 'remaining_time' if (grep { $fieldname eq $_ } TIMETRACKING_FIELDS) {
|| $fieldname eq 'estimated_time' $activity_visible = $user->is_timetracker;
|| $fieldname eq 'work_time'
|| $fieldname eq 'deadline')
{
$activity_visible = Bugzilla->user->is_timetracker;
} }
elsif ($fieldname eq 'longdescs.isprivate' elsif ($fieldname eq 'longdescs.isprivate'
&& !Bugzilla->user->is_insider && !$user->is_insider && $added)
&& $added)
{ {
$activity_visible = 0; $activity_visible = 0;
} }
...@@ -3854,14 +3849,24 @@ sub GetBugActivity { ...@@ -3854,14 +3849,24 @@ sub GetBugActivity {
$changes = []; $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->{'who'} = $who;
$operation->{'when'} = $when; $operation->{'when'} = $when;
$operation->{'fieldname'} = $change{'fieldname'} = $fieldname;
$change{'fieldname'} = $fieldname; $operation->{'attachid'} = $change{'attachid'} = $attachid;
$change{'attachid'} = $attachid;
$change{'removed'} = $removed; $change{'removed'} = $removed;
$change{'added'} = $added; $change{'added'} = $added;
if ($comment_id) { if ($comment_id) {
$change{'comment'} = Bugzilla::Comment->new($comment_id); $change{'comment'} = Bugzilla::Comment->new($comment_id);
} }
......
...@@ -355,7 +355,7 @@ sub history { ...@@ -355,7 +355,7 @@ sub history {
$bug_id = $bug->id; $bug_id = $bug->id;
$item{id} = $self->type('int', $bug_id); $item{id} = $self->type('int', $bug_id);
my ($activity) = Bugzilla::Bug::GetBugActivity($bug_id); my ($activity) = $bug->get_activity;
my @history; my @history;
foreach my $changeset (@$activity) { foreach my $changeset (@$activity) {
......
...@@ -676,8 +676,7 @@ sub update { ...@@ -676,8 +676,7 @@ sub update {
if (defined $cgi->param('delta_ts') if (defined $cgi->param('delta_ts')
&& $cgi->param('delta_ts') ne $attachment->modification_time) && $cgi->param('delta_ts') ne $attachment->modification_time)
{ {
($vars->{'operations'}) = ($vars->{'operations'}) = $bug->get_activity($attachment->id, $cgi->param('delta_ts'));
Bugzilla::Bug::GetBugActivity($bug->id, $attachment->id, $cgi->param('delta_ts'));
# The token contains the old modification_time. We need a new one. # The token contains the old modification_time. We need a new one.
$cgi->param('token', issue_hash_token([$attachment->id, $attachment->modification_time])); $cgi->param('token', issue_hash_token([$attachment->id, $attachment->modification_time]));
......
...@@ -143,9 +143,7 @@ if (defined $cgi->param('delta_ts')) ...@@ -143,9 +143,7 @@ if (defined $cgi->param('delta_ts'))
my $delta_ts_z = datetime_from($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); my $first_delta_tz_z = datetime_from($first_bug->delta_ts);
if ($first_delta_tz_z ne $delta_ts_z) { if ($first_delta_tz_z ne $delta_ts_z) {
($vars->{'operations'}) = ($vars->{'operations'}) = $first_bug->get_activity(undef, $cgi->param('delta_ts'));
Bugzilla::Bug::GetBugActivity($first_bug->id, undef,
scalar $cgi->param('delta_ts'));
$vars->{'title_tag'} = "mid_air"; $vars->{'title_tag'} = "mid_air";
......
...@@ -54,8 +54,7 @@ my $bug = Bugzilla::Bug->check($id); ...@@ -54,8 +54,7 @@ my $bug = Bugzilla::Bug->check($id);
# visible immediately due to replication lag. # visible immediately due to replication lag.
Bugzilla->switch_to_shadow_db; Bugzilla->switch_to_shadow_db;
($vars->{'operations'}, $vars->{'incomplete_data'}) = ($vars->{'operations'}, $vars->{'incomplete_data'}) = $bug->get_activity;
Bugzilla::Bug::GetBugActivity($bug->id);
$vars->{'bug'} = $bug; $vars->{'bug'} = $bug;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment