Closed EvilKarter closed 3 years ago
Thanks for posting in our issue tracker. In order to properly assist you, we need additional information:
Thanks!
This is an automated comment, triggered by adding the label status:need more info
.
You probably have some closure in your app config for functional tests - Message
holds reference to mailer, so I would check there first.
But in general you should avoid passing instance of Message
to job, since it may contain references to other parts of app and you may end up with serializing more than you expect.
Likely it can't be solved on Yii side.
ok i have solved my Problem: I have unset its public $mailer property and reattach it when it is unserialized.
Hi, I am not sure if this is a Problem of yii2-queue or codeseption. I am sending all my mails with the help of your queue-extension. For example my sendForgotPasswordMail function:
public function sendForgotPasswordMail(User $user): bool
{
$message = Yii::$app->mailer->compose([
html' => 'passwordResetToken-html',
text' => 'passwordResetToken-text',
], ['user' => $user])
->setFrom([Yii::$app->params['adminEmail'] => Yii::$app->name . ' robot'])
->setTo($this->email)
->setSubject(Yii::$app->name . ' ' . Yii::t('app', 'forgot password'));
$queueId = Yii::$app->queue->push(new MailJob([
'message' => $message,
]));
return 0 < $queueId;
}
The application works quite fine this why. But if I am running my functional tests I always get this Error: [Exception] Serialization of 'Closure' is not allowed
1 D:\wamp64\www\jobquick\www\framework\vendor\yiisoft\yii2-queue\src\serializers\PhpSerializer.php:24
2 D:\wamp64\www\jobquick\www\framework\vendor\yiisoft\yii2-queue\src\Queue.php:195
3 D:\wamp64\www\jobquick\www\framework\backend\models\ForgotPasswordForm.php:47
Line 47 of ForgotPasswordForm is 'message' => $message, from example above
I know that PHP cannot serialize anonmyous functions. But why is this code working on all environments, but the tests are failing?
Additional info