Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkp/pkp-lib#10977 Fix issues within merge user functionality #10984

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

taslangraham
Copy link
Contributor

For #10977

Copy link
Contributor

@Hafsa-Naeem Hafsa-Naeem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pluck(...)->toArray() loads all matching email_log_id values into PHP memory before running the update. and might not be optimal for large datasets. how about using?

->whereNotIn('email_log_id', function ($sub) use ($newUserId, $oldUserId) {
    $sub->select('t1.email_log_id')
        ->from(DB::raw('email_log_users as t1'))
        ->join(DB::raw('email_log_users as t2'), 't1.email_log_id', '=', 't2.email_log_id')
        ->where('t1.user_id', $newUserId)
        ->where('t2.user_id', $oldUserId);
})

@taslangraham taslangraham force-pushed the i10977-main branch 4 times, most recently from 6344caa to 2d353ef Compare March 3, 2025 14:29
@taslangraham
Copy link
Contributor Author

@Hafsa-Naeem Thanks for the review.
The suggested query produced an error - General error: 1093 You can't specify target table 'email_log_users' for update in FROM clause so I had to tweak it a bit. Please take a look

@Hafsa-Naeem
Copy link
Contributor

@taslangraham Looks good to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants