diff --git a/MailQueue.php b/MailQueue.php index 4069fe3..7c1daae 100644 --- a/MailQueue.php +++ b/MailQueue.php @@ -76,6 +76,10 @@ class MailQueue extends Mailer public function init() { parent::init(); + + if (Yii::$app->db->getTableSchema($this->table) == null) { + throw new \yii\base\InvalidConfigException('"' . $this->table . '" not found in database. Make sure the db migration is properly done and the table is created.'); + } } /** @@ -85,10 +89,6 @@ public function init() */ public function process() { - if (Yii::$app->db->getTableSchema($this->table) == null) { - throw new \yii\base\InvalidConfigException('"' . $this->table . '" not found in database. Make sure the db migration is properly done and the table is created.'); - } - $success = true; $items = Queue::find()->where(['and', ['sent_time' => NULL], ['<', 'attempts', $this->maxAttempts], ['<=', 'time_to_send', date('Y-m-d H:i:s')]])->orderBy(['created_at' => SORT_ASC])->limit($this->mailsPerRound);