Skip to content

[7.x] Notifiables no longer serialized when being queued #32039

Closed
@aaronhuisinga

Description

@aaronhuisinga
  • Laravel Version: 7.x
  • PHP Version: 7.4.x
  • Database Driver & Version: MySQL 8.x

Description:

#31675 was merged into the Laravel 7 branch to make sure the notifiables for a notification are always a collection. This has lead to several issues for us (using Vapor & SQS) where notifications are now too large for SQS to handle (Message must be shorter than 262144 bytes).

In Laravel 6.x and below, if sending a notification to a single user, the user model was serialized, which to me is the expected behavior. In 7.x, the user model is wrapped in a collection, and thus not serialized. If an application has any fields in their User model with large amounts of text, it will quickly cause the notification content to be too large to queue using SQS. The same notification being queued in Laravel 7 grew to 9627 characters from 2276 characters in Laravel 6, just due to the notifiable no longer being serialized.

As of now, I'm not certain there is a workaround for this issue, other than somehow overriding the SendQueuedNotifications class to revert this change.

Steps To Reproduce:

  1. Install Laravel 7.x
  2. Create User to receive notification
  3. Create notification with any data passed in as parameters, and make sure it uses the queue
  4. Call $user->notify() using your created notification
  5. Verify the queued content to see the User object is not serialized

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions