-
Notifications
You must be signed in to change notification settings - Fork 313
Closed
Description
Describe the bug
One of conversation has ~20k participants and when new message is added, the conversation generator crash with this mysql error: SQLSTATE[HY000]: General error: 1390 Prepared statement contains too many placeholders
To Reproduce
Steps to reproduce the behavior:
- Normal instalation
- Add conversation
- Add hundreds of thousands of participants
- Create a message and see the error: SQLSTATE[HY000]: General error: 1390 Prepared statement contains too many placeholders
Expected behavior
No error and all notifications created.
I need to refactor this createCustomNotifications method on src/Models/MessageNotification.php:
public static function createCustomNotifications($message, $conversation)
{
$notification = [];
foreach ($conversation->participants as $participation) {
$is_sender = ($message->participation_id == $participation->id) ? 1 : 0;
$notification[] = [
'messageable_id' => $participation->messageable_id,
'messageable_type' => $participation->messageable_type,
'message_id' => $message->id,
'participation_id' => $participation->id,
'conversation_id' => $conversation->id,
'is_seen' => $is_sender,
'is_sender' => $is_sender,
'created_at' => $message->created_at,
];
}
self::insert($notification);
}
How I do?
My idea: or chunk participant list in support number of MySQL, or work with jobs, sending the responsability to queue.
Metadata
Metadata
Assignees
Labels
No labels