From 82346032ecfef148e78a8d19e17c5ed41ed41d10 Mon Sep 17 00:00:00 2001 From: Dylan William Hardison Date: Thu, 21 Aug 2014 11:15:16 -0400 Subject: Bug 1056087 - contrib/merge-users.pl fails if there are no duplicate bug_user_last_visit rows --- contrib/merge-users.pl | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'contrib') diff --git a/contrib/merge-users.pl b/contrib/merge-users.pl index ddb828eef..86b209ab2 100755 --- a/contrib/merge-users.pl +++ b/contrib/merge-users.pl @@ -154,12 +154,17 @@ my $dupe_ids = $dbh->selectcol_arrayref(" SELECT earlier.id FROM bug_user_last_visit as earlier INNER JOIN bug_user_last_visit as later - ON (earlier.user_id != later.user_id AND earlier.last_visit_ts < later.last_visit_ts + ON (earlier.user_id != later.user_id + AND earlier.last_visit_ts < later.last_visit_ts AND earlier.bug_id = later.bug_id) WHERE (earlier.user_id = ? OR earlier.user_id = ?) AND (later.user_id = ? OR later.user_id = ?)", undef, $old_id, $new_id, $old_id, $new_id); -$dbh->do("DELETE FROM bug_user_last_visit WHERE " . $dbh->sql_in('id', $dupe_ids)); + +if (@$dupe_ids) { + $dbh->do("DELETE FROM bug_user_last_visit WHERE " . + $dbh->sql_in('id', $dupe_ids)); +} # Migrate records from old user to new user. foreach my $table (keys %changes) { -- cgit v1.2.3-24-g4f1b