Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error sending many notifications in ActiveRecordChannel #17

Closed
gitrequests opened this issue Nov 6, 2018 · 0 comments
Closed

Error sending many notifications in ActiveRecordChannel #17

gitrequests opened this issue Nov 6, 2018 · 0 comments

Comments

@gitrequests
Copy link
Contributor

gitrequests commented Nov 6, 2018

Find this issue when applying batch action...

Try to send notifications like this:

Yii::$app->notifier->send($user1, $notification1);
Yii::$app->notifier->send($user1, $notification2);
Yii::$app->notifier->send($user2, $notification3);

I know that notifications may sending in array... But it is impossible in some use cases.

Right now, if many noty sending in this way, second query (and the following) in ActiveRecordChannel.php loads Existing Model! And we do insert() function on Existing model!

In my project this issue do not sending some data in Database ONLY in batch insert (there is some other fields in DB, since i use a different ActiveRecordChannel):
screenshot from 2018-11-06 18-25-58

My solution is to create new Model before load Data (Change in ActiveRecordChannel.php from line 46):

$class = $this->model;
$model = \Yii::createObject($class::className());

if ($model->load($data, '')) {
      return $model->insert();
}

This issue need to checking by contributors, since i use extending ActiveRecordChannel. But inserting on existing Model is not right way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant