Error when a user disables notifications

OJS 3.4.0.8
Error when a user disables notifications


image

If, for example, a user disables ‘Discussion activity’ notifications, a ‘blocked_notification’ record is created in the ‘notification_subscription_settings’ table and the PKPNotificationOperationManager::createNotification() function returns null because the notification type is blocked, so the call to the $mailable->allowUnsubscribe($notification) function causes a PHP error:

[Fri Dec 20 13:26:44.299598 2024] [php:error] [pid 20092:tid 1920] [client 127.0.0.1:57282] PHP Fatal error: Uncaught TypeError: PKP\mail\mailables\DiscussionSubmission::allowUnsubscribe(): Argument #1 ($notification) must be of type APP\notification\Notification, null given, called in C:\xampp\htdocs\ojs3408\lib\pkp\controllers\grid\queries\QueriesGridHandler.php on line 688 and defined in C:\xampp\htdocs\ojs3408\lib\pkp\classes\mail\traits\Unsubscribe.php:49\nStack trace:\n#0 C:\xampp\htdocs\ojs3408\lib\pkp\controllers\grid\queries\QueriesGridHandler.php(688): PKP\mail\mailables\DiscussionSubmission->allowUnsubscribe(NULL)\n#1 [internal function]: PKP\controllers\grid\queries\QueriesGridHandler->updateQuery(Array, Object(APP\core\Request))\n#2 C:\xampp\htdocs\ojs3408\lib\pkp\classes\core\PKPRouter.php(334): call_user_func(Array, Array, Object(APP\core\Request))\n#3 C:\xampp\htdocs\ojs3408\lib\pkp\classes\core\PKPComponentRouter.php(291): PKP\core\PKPRouter->_authorizeInitializeAndCallRequest(Array, Object(APP\core\Request), Array)\n#4 C:\xampp\htdocs\ojs3408\lib\pkp\classes\core\Dispatcher.php(165): PKP\core\PKPComponentRouter->route(Object(APP\core\Request))\n#5 C:\xampp\htdocs\ojs3408\lib\pkp\classes\core\PKPApplication.php(388): PKP\core\Dispatcher->dispatch(Object(APP\core\Request))\n#6 C:\xampp\htdocs\ojs3408\index.php(21): PKP\core\PKPApplication->execute()\n#7 {main}\n thrown in C:\xampp\htdocs\ojs3408\lib\pkp\classes\mail\traits\Unsubscribe.php on line 49

Hi @sbir,

Are you sure you’re using OJS 3.4.0-8? This should already be fixed in that release. See: [OJS3.4] Opening a new discussion with a participant who has disabled new discussion notifications does not work · Issue #10385 · pkp/pkp-lib · GitHub

Regards,
Alec Smecher
Public Knowledge Project Team

Yes, OJS version is 3.4.0.8
As you indicate in the message, I can tell you that it is fixed, but not completely.
I have a user with the role of section-editor, who has ‘Discussion added’ disabled, as you say, if I add a new discussion with that user everything works fine. But if I assign that user to the submission, the system performs two actions:

  1. assigning the user to the submission
  2. creation of a new discussion with the subject ‘You have been assigned as an editor on a submission to journalName’. It is at this precise moment that the error occurs and the screen looks like this:

This is not really a serious error because if I refresh the browser, the assignment as a new editor has been completed and the new discussion has been created.
I would like to take this opportunity to notify you that I posted another problem that has to do with ‘Email footer discussion threads’ (Email footer discussion threads -> Reply to this comment at: You don't currently have access to that stage of the workflow - #2 by sbir).
Thank you

Hi @sbir,

Can you check the PHP error log for the message that appears when you click the OK button?

Regards,
Alec Smecher
Public Knowledge Project Team

Hello @asmecher
here you are:
[Mon Dec 23 18:33:42.863310 2024] [php:error] [pid 513846] [client 192.168.0.254:52397] PHP Fatal error: Uncaught TypeError: PKP\mail\mailables\DiscussionSubmission::allowUnsubscribe(): Argument #1 ($notification) must be of type APP\notification\Notification, null given, called in /var/www/ojs3408/lib/pkp/controllers/grid/users/stageParticipant/form/PKPStageParticipantNotifyForm.php on line 237 and defined in /var/www/ojs3408/lib/pkp/classes/mail/traits/Unsubscribe.php:49\nStack trace:\n#0 /var/www/ojs3408/lib/pkp/controllers/grid/users/stageParticipant/form/PKPStageParticipantNotifyForm.php(237): PKP\mail\mailables\DiscussionSubmission->allowUnsubscribe()\n#1 /var/www/ojs3408/lib/pkp/controllers/grid/users/stageParticipant/form/PKPStageParticipantNotifyForm.php(155): PKP\controllers\grid\users\stageParticipant\form\PKPStageParticipantNotifyForm->sendMessage()\n#2 /var/www/ojs3408/lib/pkp/controllers/grid/users/stageParticipant/form/AddParticipantForm.php(286): PKP\controllers\grid\users\stageParticipant\form\PKPStageParticipantNotifyForm->execute()\n#3 /var/www/ojs3408/lib/pkp/controllers/grid/users/stageParticipant/StageParticipantGridHandler.php(345): PKP\controllers\grid\users\stageParticipant\form\AddParticipantForm->execute()\n#4 [internal function]: PKP\controllers\grid\users\stageParticipant\StageParticipantGridHandler->saveParticipant()\n#5 /var/www/ojs3408/lib/pkp/classes/core/PKPRouter.php(334): call_user_func()\n#6 /var/www/ojs3408/lib/pkp/classes/core/PKPComponentRouter.php(291): PKP\core\PKPRouter->_authorizeInitializeAndCallRequest()\n#7 /var/www/ojs3408/lib/pkp/classes/core/Dispatcher.php(165): PKP\core\PKPComponentRouter->route()\n#8 /var/www/ojs3408/lib/pkp/classes/core/PKPApplication.php(395): PKP\core\Dispatcher->dispatch()\n#9 /var/www/ojs3408/index.php(21): PKP\core\PKPApplication->execute()\n#10 {main}\n thrown in /var/www/ojs3408/lib/pkp/classes/mail/traits/Unsubscribe.php on line 49, referer: https://desarrollo22.ojs3408.upct.es/index.php/sbir/workflow/index/2/1

This topic was automatically closed after 9 days. New replies are no longer allowed.

Hi @sbir,

Thanks, that helps. Try this commit:

https://github.com/pkp/pkp-lib/commit/34fd3c8fd9aad7846be3ef3cb00fdd5ae0e7693d

It should resolve the error you reported just above. It’ll be included in the next 3.4.0-x release.

Regards,
Alec Smecher
Public Knowledge Project Team

Thank you very much @asmecher
I will apply the commit for the time being and waiting for the new OJS version.
By the way, did you take a look at Email footer discussion threads -> Reply to this comment at: You don't currently have access to that stage of the workflow - #2 by sbir
Regards
Carlos

This topic was automatically closed after 13 days. New replies are no longer allowed.