humhub / mail

A private messaging system for direct communication.
https://marketplace.humhub.com/module/mail
29 stars 50 forks source link

Error in the log with version 3.1.0 #351

Closed marc-farre closed 1 year ago

marc-farre commented 1 year ago

With the new version 3.1.0 I have the following error in the log each time I open a conversation (no visible bug, the module works well):

Call to a member function is() on null in
/var/www/humhub/protected/modules/mail/widgets/ConversationStateBadge.php:69
Stack trace:
#0
/var/www/humhub/protected/modules/mail/widgets/ConversationStateBadge.php(53):
humhub\modules\mail\widgets\ConversationStateBadge->isOwn()
#1
/var/www/humhub/protected/modules/mail/widgets/ConversationStateBadge.php(29):
humhub\modules\mail\widgets\ConversationStateBadge->renderInfoText()
#2
/var/www/humhub/protected/humhub/components/Widget.php(63):
humhub\modules\mail\widgets\ConversationStateBadge->run()
#3
/var/www/humhub/protected/modules/mail/widgets/views/conversationState.php(19):
humhub\components\Widget::widget()
#4
/var/www/humhub/protected/vendor/yiisoft/yii2/base/View.php(347):
require('...')
#5
/var/www/humhub/protected/vendor/yiisoft/yii2/base/View.php(257):
yii\base\View->renderPhpFile()
#6
/var/www/humhub/protected/vendor/yiisoft/yii2/base/View.php(156):
yii\base\View->renderFile()
#7
/var/www/humhub/protected/vendor/yiisoft/yii2/base/Widget.php(249):
yii\base\View->render()
#8
/var/www/humhub/protected/modules/mail/widgets/ConversationEntry.php(73):
yii\base\Widget->render()
#9
/var/www/humhub/protected/modules/mail/widgets/ConversationEntry.php(54):
humhub\modules\mail\widgets\ConversationEntry->runState()
#10
/var/www/humhub/protected/humhub/components/Widget.php(63):
humhub\modules\mail\widgets\ConversationEntry->run()
#11
/var/www/humhub/protected/modules/mail/widgets/Messages.php(43):
humhub\components\Widget::widget()
#12
/var/www/humhub/protected/humhub/components/Widget.php(63):
humhub\modules\mail\widgets\Messages->run()
#13
/var/www/humhub/protected/modules/mail/views/mail/conversation.php(45):
humhub\components\Widget::widget()
#14
/var/www/humhub/protected/vendor/yiisoft/yii2/base/View.php(347):
require('...')
#15
/var/www/humhub/protected/vendor/yiisoft/yii2/base/View.php(257):
yii\base\View->renderPhpFile()
#16
/var/www/humhub/protected/humhub/modules/ui/view/components/View.php(240):
yii\base\View->renderFile()
#17
/var/www/humhub/protected/vendor/yiisoft/yii2/web/Controller.php(50):
humhub\modules\ui\view\components\View->renderAjax()
#18
/var/www/humhub/protected/modules/mail/controllers/MailController.php(79):
yii\web\Controller->renderAjax()
#19 [internal function]:
humhub\modules\mail\controllers\MailController->actionShow()
#20
/var/www/humhub/protected/vendor/yiisoft/yii2/base/InlineAction.php(57):
call_user_func_array()
#21
/var/www/humhub/protected/vendor/yiisoft/yii2/base/Controller.php(178):
yii\base\InlineAction->runWithParams()
#22
/var/www/humhub/protected/vendor/yiisoft/yii2/base/Module.php(552):
yii\base\Controller->runAction()
#23
/var/www/humhub/protected/vendor/yiisoft/yii2/web/Application.php(103):
yii\base\Module->runAction()
#24
/var/www/humhub/protected/vendor/yiisoft/yii2/base/Application.php(384):
yii\web\Application->handleRequest()
#25 /var/www/humhub/index.php(25):
yii\base\Application->run()
#26 {main}
in
/var/www/humhub/protected/modules/mail/widgets/Messages.php:51
in
/var/www/humhub/protected/humhub/components/Widget.php:63
in
/var/www/humhub/protected/modules/mail/views/mail/conversation.php:45
yurabakhtin commented 1 year ago

@luke- @marc-farre Fixed in PR https://github.com/humhub/mail/pull/352. I think it is related to this https://github.com/humhub/mail/pull/344. The error can be fixed by run Integrity Check tool. Also I am thinking why the table message_entry has no foreign key in order to delete when user is deleted, probably we should create it.

luke- commented 1 year ago

@yurabakhtin The mail module should use the User delete Event and delete corresponding Message entries. In addition, an FK would also be good. But the deletion should be done via events. (e.g. delete related files, a conversation must be deleted if the last message entry was deleted).

For corrupt dbs the current PR is ok

yurabakhtin commented 1 year ago

@luke-

The mail module should use the User delete Event and delete corresponding Message entries. But the deletion should be done via events.

Yes, we have the deletion of a message entry via events here - https://github.com/humhub/mail/blob/master/Events.php#L106-L108

In addition, an FK would also be good.

Ok, I will add FK, because not sure why db is corrupted sometimes.

luke- commented 1 year ago

@yurabakhtin Were there any issue in the past. Or why do we need the "[DELETED]" condition?

yurabakhtin commented 1 year ago

@luke-

Were there any issue in the past.

I have found only single issue where the [DELETED] was added for records with not existing user:

Or why do we need the "[DELETED]" condition?

I have added the [DELETED] there in order to fix error when DB is broken until it is not fixed by Integrity Check tool.

In addition, an FK would also be good.

Done in commit https://github.com/humhub/mail/pull/352/commits/5391a1205291a5aa1332d4f4fefe295e4f008de0.

marc-farre commented 1 year ago

@yurabakhtin thanks!