Skip to content

Commit c516e35

Browse files
committed
Bug 1067410 - Modification time wrong for deleted flags in review schema
1 parent fb7ed7b commit c516e35

3 files changed

Lines changed: 29 additions & 16 deletions

File tree

Bugzilla/Flag.pm

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ sub update {
484484
}
485485

486486
# BMO - provide a hook which passes the flag object
487-
Bugzilla::Hook::process('flag_updated', {flag => $self, changes => $changes});
487+
Bugzilla::Hook::process('flag_updated', {flag => $self, changes => $changes, timestamp => $timestamp});
488488

489489
return $changes;
490490
}
@@ -540,6 +540,10 @@ sub update_flags {
540540
# These flags have been deleted.
541541
foreach my $old_flag (values %old_flags) {
542542
$class->notify(undef, $old_flag, $self, $timestamp);
543+
544+
# BMO - provide a hook which passes the timestamp,
545+
# because that isn't passed to remove_from_db().
546+
Bugzilla::Hook::process('flag_deleted', {flag => $old_flag, timestamp => $timestamp});
543547
$old_flag->remove_from_db();
544548
}
545549

@@ -637,6 +641,11 @@ sub force_retarget {
637641
# Track deleted attachment flags.
638642
push(@removed, $class->snapshot([$flag])) if $flag->attach_id;
639643
$class->notify(undef, $flag, $bug || $flag->bug);
644+
645+
# BMO - provide a hook which passes the timestamp,
646+
# because that isn't passed to remove_from_db().
647+
my ($timestamp) = $dbh->selectrow_array('SELECT LOCALTIMESTAMP(0)');
648+
Bugzilla::Hook::process('flag_deleted', {flag => $flag, timestamp => $timestamp});
640649
$flag->remove_from_db();
641650
}
642651
}

extensions/Review/Extension.pm

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ sub object_end_of_create {
320320
_adjust_request_count($object, +1);
321321
}
322322
if (_is_countable_flag($object)) {
323-
$self->_log_flag_state_activity($object, $object->status);
323+
$self->_log_flag_state_activity($object, $object->status, $object->modification_date);
324324
}
325325
}
326326

@@ -393,25 +393,27 @@ sub object_end_of_update {
393393

394394
sub flag_updated {
395395
my ($self, $args) = @_;
396-
my $flag = $args->{flag};
397-
my $changes = $args->{changes};
396+
my $flag = $args->{flag};
397+
my $timestamp = $args->{timestamp};
398+
my $changes = $args->{changes};
398399

399400
return unless scalar(keys %$changes);
400401
if (_is_countable_flag($flag)) {
401-
$self->_log_flag_state_activity( $flag, $flag->status );
402+
$self->_log_flag_state_activity($flag, $flag->status, $timestamp);
402403
}
403404
}
404405

405-
sub object_before_delete {
406+
sub flag_deleted {
406407
my ($self, $args) = @_;
407-
my $object = $args->{object};
408+
my $flag = $args->{flag};
409+
my $timestamp = $args->{timestamp};
408410

409-
if (_is_countable_flag($object) && $object->requestee_id && $object->status eq '?') {
410-
_adjust_request_count($object, -1);
411+
if (_is_countable_flag($flag) && $flag->requestee_id && $flag->status eq '?') {
412+
_adjust_request_count($flag, -1);
411413
}
412414

413-
if (_is_countable_flag($object)) {
414-
$self->_log_flag_state_activity($object, 'X');
415+
if (_is_countable_flag($flag)) {
416+
$self->_log_flag_state_activity($flag, 'X', $timestamp, Bugzilla->user->id);
415417
}
416418
}
417419

@@ -423,17 +425,19 @@ sub _is_countable_flag {
423425
}
424426

425427
sub _log_flag_state_activity {
426-
my ($self, $flag, $status) = @_;
428+
my ($self, $flag, $status, $timestamp, $setter_id) = @_;
429+
430+
$setter_id //= $flag->setter_id;
427431

428432
Bugzilla::Extension::Review::FlagStateActivity->create({
429-
flag_when => $flag->modification_date,
433+
flag_when => $timestamp,
434+
setter_id => $setter_id,
435+
status => $status,
430436
type_id => $flag->type_id,
431437
flag_id => $flag->id,
432-
setter_id => $flag->setter_id,
433438
requestee_id => $flag->requestee_id,
434439
bug_id => $flag->bug_id,
435440
attachment_id => $flag->attach_id,
436-
status => $status,
437441
});
438442
}
439443

extensions/Review/lib/WebService.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ GET /rest/review/flag_activity/setter/C<setter>
366366
367367
GET /rest/review/flag_activity/type_id/C<type_id>
368368
369-
GET /rest/review/flag_activity/type/C<type_name>
369+
GET /rest/review/flag_activity/type_name/C<type_name>
370370
371371
GET /rest/review/flag_activity
372372

0 commit comments

Comments
 (0)