Notifications error for deleted users
marc-farre opened this issue · comments
When a user of a conversation is deleted, I get the following error in the log:
Could not send notification e-mail to: deleted-3198. Error:foreach()
argument must be of type array|object, null given
in
/var/www/humhub/protected/modules/mail/models/MessageNotification.php:63
in
/var/www/humhub/protected/modules/mail/models/MessageNotification.php:44
in
/var/www/humhub/protected/modules/mail/models/MessageEntry.php:51
$_POST = [
'ReplyForm' => [
'message' => 'The message'
]
]
'REQUEST_URI' => '/mail/mail/reply?id=4699'
Perhaps, in Message::getUsers()
(here) we could add:
->where(['user.status' => User::STATUS_ENABLED])
But I'm not quite sure if it solves the bug, as the error is foreach() argument must be of type array|object, null given
. I don't understand why. It seams to be in MessageNotification::notifyAll()
(here) that $this->message->users
is returning null
instead of an array.
I've checked in the DB, and I have 5 active users for this conversion and 1 deleted user.
@luke- @marc-farre Fixed in PR #359, the problem was in that a deleted user has email === NULL
but the method yii\symfonymailer\Message::setTo()
exptects array
or string
.
@yurabakhtin Thanks!