Closed Bug 1027182 Opened 6 years ago Closed 6 years ago

merge-users.pl - SQL to remove bug_user_last_visit not correct

Categories

(Bugzilla :: Administration, task)

task
Not set
normal

Tracking

()

RESOLVED FIXED
Bugzilla 5.0

People

(Reporter: c1541, Assigned: dkl)

References

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64; Trident/7.0; .NET4.0E; .NET4.0C; Media Center PC 6.0; .NET CLR 3.5.30729; .NET CLR 2.0.50727; .NET CLR 3.0.30729; InfoPath.3; rv:11.0) like Gecko

Steps to reproduce:

The SQL adding in Bug 1021218 does not restrict the "later" table to just the users being merged, so it may remove the last visit data for both users rather than keeping the later one.

For example: Support users 1 and 2 are to be merged and for bug 1 the both last visited it in 2013 and that there is also user 3 who last visited it in 2014. Then with the SQL from 1021218, the last visited records for both users 1 and 2 would be deleted.

To fix it, change:
-     WHERE (earlier.user_id = ? OR earlier.user_id = ?)",
-    undef, $old_id, $new_id);
to
+     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);
Depends on: 1021218
Component: Bugzilla-General → Administration
Attached patch 1027182_1.patchSplinter Review
Thanks for the patch. Looks good so asking for review.
Assignee: general → dkl
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Attachment #8442265 - Flags: review?(glob)
Comment on attachment 8442265 [details] [diff] [review]
1027182_1.patch

Review of attachment 8442265 [details] [diff] [review]:
-----------------------------------------------------------------

r=glob

::: contrib/merge-users.pl
@@ +154,5 @@
>             INNER JOIN bug_user_last_visit as later
>             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 = ?)",

nit: indent the AND line by 4 spaces
Attachment #8442265 - Flags: review?(glob) → review+
Flags: approval?
Target Milestone: --- → Bugzilla 5.0
Flags: approval? → approval+
To ssh://gitolite3@git.mozilla.org/bugzilla/bugzilla.git
   70b1cb4..2f10cf7  master -> master
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.