diff options
author | Florian Pritz <bluewind@xinu.at> | 2018-06-07 18:02:54 +0200 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2018-12-06 11:08:18 +0100 |
commit | 3eeeaf77cc6d7f78df26508b8e87e4df69db2a44 (patch) | |
tree | efa76cb469d7600db2c510d60527623791cd247b | |
parent | 24f349ce4b634e5445706a3bc4860741c8f40281 (diff) | |
download | bugzilla-3eeeaf77cc6d7f78df26508b8e87e4df69db2a44.tar.gz bugzilla-3eeeaf77cc6d7f78df26508b8e87e4df69db2a44.tar.xz |
Flyspray: Mark duplicate bugs only once all bugs are imported
Sometimes eariler bugs are marked as duplicate of later ones so doing it
before all are imported won't work.
Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rw-r--r-- | Bugzilla/Migrate/Flyspray.pm | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/Bugzilla/Migrate/Flyspray.pm b/Bugzilla/Migrate/Flyspray.pm index abce3ae12..5ea70d8a8 100644 --- a/Bugzilla/Migrate/Flyspray.pm +++ b/Bugzilla/Migrate/Flyspray.pm @@ -16,6 +16,8 @@ use parent qw(Bugzilla::Migrate); use Bugzilla::Constants; use Bugzilla::Util qw(validate_email_syntax); use Bugzilla::DB; +use Bugzilla::User; +use Bugzilla::Bug; use IO::File; use List::Util qw(first none); @@ -440,23 +442,6 @@ sub _read_bugs { who => $self->_get_username($history->{user_id}), bug_when => $self->parse_date($history->{event_date}), }; - - push @{$bug->{comments}}, - { - type => CMT_DUPE_OF, - extra_data => int($1), - who => $self->_get_username($history->{user_id}), - bug_when => $self->parse_date($history->{event_date}), - }; - - push @{$self->{bug_map}->{int($1)}->{comments}}, - { - type => CMT_HAS_DUPE, - extra_data => $row->{task_id}, - who => $self->_get_username($history->{user_id}), - bug_when => $self->parse_date($history->{event_date}), - } - if defined $self->{bug_map}->{int($1)}; } } } @@ -584,12 +569,33 @@ sub after_insert { my ($self) = @_; $self->debug("Marking duplicate bugs"); - $self->debug($self->{dupes}, 3); for my $entry (@{$self->{dupes}}) { my $dupeOf_bug = Bugzilla::Bug->new($entry->{dupe_of}); $self->{dbh}->do("INSERT INTO duplicates (dupe_of, dupe) VALUES (?, ?)", undef, $entry->{dupe_of}, $entry->{dupe}) unless defined $dupeOf_bug->{error}; + + my $dupe_bug = Bugzilla::Bug->new($entry->{dupe}); + + $self->_insert_comments( + $dupe_bug, + [{ + type => CMT_DUPE_OF, + extra_data => $entry->{dupe_of}, + who => $entry->{who}, + bug_when => $entry->{bug_when}, + }] + ); + + $self->_insert_comments( + $dupeOf_bug, + [{ + type => CMT_HAS_DUPE, + extra_data => $entry->{dupe}, + who => $entry->{who}, + bug_when => $entry->{bug_when}, + }] + ); } } |