dereuromark / cakephp-queue

Queue plugin for CakePHP - simple, pure PHP and without dependencies.
MIT License
306 stars 137 forks source link

Serialization of 'PDO' is not allowed - Queue.Email Task with Mailer object #291

Closed LordSimal closed 3 years ago

LordSimal commented 3 years ago
Exception: Serialization of 'PDO' is not allowed

<my-project-dir>/vendor/dereuromark/cakephp-queue/src/Model/Table/QueuedJobsTable.php:177
<my-project-dir>/src/Utility/AlfredJIRA.php:87

The code in src/Utility/AlfredJIRA.php:87 is as follows:

      $this->QueuedJobs->createJob('Queue.Email', [
        'settings' => $this->getMailer( 'Sunlime' ),
        'action' => 'notifyDuedateChanges',
        'vars' => [ $this->msg_array ]
      ]);

$this->msg_array here is just a simple associative array without any objects in them.

I think the problem here is the fact, that createJob() tries to serialise the data which contains a Mailer Object in the settings key. But I am not aware of how to fix that.

Versions

LordSimal commented 3 years ago

The Problem is the fact, that I tried to load the models in the construct() method inside my mailer. I had to refactor that so I load the model inside the mail function, not the construct method.