diff options
author | Byron Jones <bjones@mozilla.com> | 2013-09-05 08:19:15 +0200 |
---|---|---|
committer | Byron Jones <bjones@mozilla.com> | 2013-09-05 08:19:15 +0200 |
commit | 1b6f172daa92499f2a2bd7a9341f6617abc5e0e2 (patch) | |
tree | 3433009b08e1d6f90ab9e03540ad89929de679e0 /extensions | |
parent | 31ffd236e011d56a6065f47693e9bc091104a94e (diff) | |
download | bugzilla-1b6f172daa92499f2a2bd7a9341f6617abc5e0e2.tar.gz bugzilla-1b6f172daa92499f2a2bd7a9341f6617abc5e0e2.tar.xz |
Bug 912479: merge-users.pl causes foreign key constraint errors in the user-profile tables
Diffstat (limited to 'extensions')
-rw-r--r-- | extensions/UserProfile/Extension.pm | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/extensions/UserProfile/Extension.pm b/extensions/UserProfile/Extension.pm index 72bbe261b..43213be54 100644 --- a/extensions/UserProfile/Extension.pm +++ b/extensions/UserProfile/Extension.pm @@ -178,6 +178,25 @@ sub reorg_move_bugs { print "Updated $count users.\n"; } +sub merge_users_before { + my ($self, $args) = @_; + my ($old_id, $new_id) = @$args{qw(old_id new_id)}; + # when users are merged, we have to delete all the statistics for both users + # we'll recalcuate the stats after the merge + print "deleting user profile statistics for $old_id and $new_id\n"; + my $dbh = Bugzilla->dbh; + foreach my $table (qw( profiles_statistics profiles_statistics_status profiles_statistics_products )) { + $dbh->do("DELETE FROM $table WHERE " . $dbh->sql_in('user_id', [ $old_id, $new_id ])); + } +} + +sub merge_users_after { + my ($self, $args) = @_; + my $new_id = $args->{new_id}; + print "generating user profile statistics $new_id\n"; + update_statistics_by_user($new_id); +} + sub webservice_user_get { my ($self, $args) = @_; my ($service, $users) = @$args{qw(webservice users)}; |