laravel邮件队列-数据不足,无法反序列化 [英] laravel mail queueing - Insufficient data for unserializing

查看:360
本文介绍了laravel邮件队列-数据不足,无法反序列化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用

Ubuntu
laravel 4.2
beanstalked

当我尝试

php artisan queue:work

它返回

 [ErrorException]                                                  
  Insufficient data for unserializing - 1403 required, 218 present  

邮件功能(信任包)

Mail::queueOn(
                    Config::get('confide::email_queue'),
                    Config::get('confide::email_account_confirmation'),
                    compact('user'),
                    function ($message) use ($user) {
                        $message
                            ->to($user->email, $user->username)
                            ->subject(Lang::get('confide::confide.email.account_confirmation.subject'));
                    }
                );

推荐答案

我也遇到了这个问题,我想我已经找到了解决方案.

I came across this problem as well and I think I've got the solution.

当电子邮件进入队列时,Laravel需要序列化电子邮件的所有数据,以便稍后在处理队列时可以将其重新调用.

When an email gets queued, Laravel needs to serialize all of the email's data so it can be recalled later on when the queue is being processed.

问题是,当您尝试序列化Eloquent模型的实例(在这种情况下为$ user)时,序列化的字符串将太大而无法存储在队列中.

The problem is that when you try to serialize an instance of an Eloquent model ($user in this case) the serialized string will be too large to be stored in the queue.

要解决此问题,请在调用Mail :: queueOn之前将所需的特定值存储在数组中,并将该数组附加到作为Mail :: queueOn的参数传递的闭包上.

To get around this, store the specific values you need in an array before calling Mail::queueOn and attach that array to the closure you pass as an argument to Mail::queueOn.

$data = array(
    'email' => $user->email,
    'username' => $user->username
);

Mail::queueOn(
    Config::get('confide::email_queue'),
    Config::get('confide::email_account_confirmation'),
    compact('user'),
    function ($message) use ($data) {
        $message
            ->to($data['email'], $data['username'])
            ->subject(Lang::get('confide::confide.email.account_confirmation.subject'));
    }
);

我在查看此问题在GitHub上时找到了解决方案

这篇关于laravel邮件队列-数据不足,无法反序列化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆