Skip to content

Commit

Permalink
#10977 Fix issues within merge user functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
taslangraham committed Feb 25, 2025
1 parent 6bac875 commit 9e1c6d3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
15 changes: 8 additions & 7 deletions classes/log/Repository.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @file classes/log/Repository.php
*
Expand Down Expand Up @@ -107,13 +108,13 @@ public function changeUser(int $oldUserId, int $newUserId)

DB::table('email_log_users')
->where('user_id', $oldUserId)
->whereNotIn('email_log_id', function ($query) use ($newUserId, $oldUserId) {
$query->select('t1.email_log_id')
->from(DB::table('email_log_users')->as('t1'))
->join(DB::table('email_log_users')->as('t2'), 't1.email_log_id', '=', 't2.email_log_id')
->where('t1.user_id', $newUserId)
->where('t2.user_id', $oldUserId);
})->update(['user_id' => $newUserId])
->whereNotIn('email_log_id', DB::table('email_log_users as t1')
->select('t1.email_log_id')
->join('email_log_users as t2', 't1.email_log_id', '=', 't2.email_log_id')
->where('t1.user_id', $newUserId)
->where('t2.user_id', $oldUserId)
->pluck('t1.email_log_id')
->toArray())->update(['user_id' => $newUserId])
];
}

Expand Down
3 changes: 2 additions & 1 deletion classes/user/Repository.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @file classes/user/Repository.php
*
Expand Down Expand Up @@ -375,7 +376,7 @@ public function mergeUsers(int $oldUserId, int $newUserId)
if (!$exists) {
UserUserGroup::create([
'userId' => $newUserId,
'userGroupId' => $userUserGroup->id,
'userGroupId' => $userUserGroup->userGroupId,
'dateStart' => $userUserGroup->dateStart,
'dateEnd' => $userUserGroup->dateEnd,
'masthead' => $userUserGroup->masthead,
Expand Down

0 comments on commit 9e1c6d3

Please sign in to comment.