summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDylan William Hardison <dylan@hardison.net>2014-08-26 15:19:04 +0200
committerDylan William Hardison <dylan@hardison.net>2014-08-26 15:24:47 +0200
commitf95d29501ddc10e788eac9859cf57bdb59ac29d3 (patch)
tree1fe845a247494b84569b7d50bf3370e241080570
parentb08625845958b4cf886c2577529afd091c5f9fac (diff)
downloadbugzilla-f95d29501ddc10e788eac9859cf57bdb59ac29d3.tar.gz
bugzilla-f95d29501ddc10e788eac9859cf57bdb59ac29d3.tar.xz
Bug 1056087 - contrib/merge-users.pl fails if there are no duplicate bug_user_last_visit rows
r/a=glob
-rwxr-xr-xcontrib/merge-users.pl9
1 files changed, 7 insertions, 2 deletions
diff --git a/contrib/merge-users.pl b/contrib/merge-users.pl
index 28a378e1c..aeb8156ad 100755
--- a/contrib/merge-users.pl
+++ b/contrib/merge-users.pl
@@ -171,12 +171,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) {