Open SOHELAHMED7 opened 1 year ago
Patch for this
'queue-monitor' => [
'class' => \zhuravljov\yii\queue\monitor\Module::class,
// Issue reported: https://github.com/yiisoft/yii2-queue/issues/458
'on beforeAction' => function ($event) {
Yii::$container->setSingletons([\PDO::class => function ($container, $params, $config) {
return new \PDO(
Yii::$app->db->dsn,
Yii::$app->db->username,
Yii::$app->db->password,
Yii::$app->db->attributes,
);
}
]);
},
],
More info to reproduce this issue:
I was using https://github.com/mikk150/yii2-queue-mailer to send email in queue.
MailJob has properties:
/**
* @var string|array|MessageInterface
*/
public $message;
It is stored in queue push record table -> job_data
(blob) col as
"message": {
"=class=": "yii\\swiftmailer\\Message",
"mailer": {
"=class=": "mikk150\\queuemailer\\Mailer",
"mailer": {
"=class=": "yii\\swiftmailer\\Mailer",
"messageClass": "yii\\swiftmailer\\Message",
"enableSwiftMailerLogging": false,
"htmlLayout": "layouts/html",
"textLayout": "layouts/text",
"messageConfig": [],
"useFileTransport": true,
"fileTransportPath": "@runtime/mail",
"fileTransportCallback": null
},
"queue": {
"=class=": "yii\\queue\\db\\Queue",
"db": {
"=class=": "yii\\db\\Connection",
"dsn": "mysql:host=ui;dbname=1111",
"username": "11",
"password": "111",
"attributes": null,
"pdo": {
"=class=": "PDO" <--- no arguments for constructor here
},
What steps will reproduce the problem?
DB is MariaDB
Queue type is DB queue
I have a typical queue job. Its push and exec operation is carried out properly.
When I go to queue job monitor page, I get this error:
PDOException: invalid data source name
invalid data source name
What's expected?
No error. A normal web page showing statuses of queue jobs
What do you get instead?
Above error
Additional info
yiisoft/yii2-queue: 2.3.4
zhuravljov/yii2-queue-monitor: 0.3.4