Problem/Motivation
Error in queue
TypeError: forum_notifications_subscription_email_queue(): Argument #4 ($user_id) must be of type string, null given, called in /code/web/modules/contrib/forum_notifications_subscription/forum_notifications_subscription.module on line 373 in forum_notifications_subscription_email_queue() (line 406 of /code/web/modules/contrib/forum_notifications_subscription/forum_notifications_subscription.module)
Additionally, the subscription button is not displayed correctly in the forums
Steps to reproduce
Subscribe to the notifications and send the emails with the Cron
Proposed resolution
In forum_notifications_subscription.module, line 373, a NULL value is sending
if ($frequency->getFrequency() == 'Daily Digest Emails') {
forum_notifications_subscription_email_queue($email, $params['title'], $params['message'], $subscriberUser->id(), 'Daily Digest Emails');
}
elseif ($frequency->getFrequency() == 'Single Emails') {
\Drupal::logger('forum_notifications_subscription')
->notice($settings['cron'] . " Cron value");
if ($settings['cron']) {
forum_notifications_subscription_email_queue($email, $params['title'], $params['message'], NULL, 'Single Emails');
}
else {
forum_notifications_subscription_emailer('forum_notifications_subscription', 'single_email_queue', $email, $params['title'], $params['message']);
}
}
And this value is received by this function in line 406, this function need a string value.
function forum_notifications_subscription_email_queue(string $to, string $subject, string $message, string $user_id, string $queue_type) {
$data['to'] = $to;
$data['title'] = $subject;
$data['message'] = $message;
$queue_factory = \Drupal::service('queue');
if ($queue_type == 'Daily Digest Emails') {
$data['user_id'] = $user_id;
$queue = $queue_factory->get('daily_digest_email_queue');
$queue->createQueue();
$queue->createItem($data);
}
elseif ($queue_type == 'Single Emails') {
$queue = $queue_factory->get('single_email_queue');
$queue->createQueue();
$queue->createItem($data);
}
}
My "easy solution" is change the NULL value for a number 0, Line 373
if ($settings['cron']) {
forum_notifications_subscription_email_queue($email, $params['title'], $params['message'],0, 'Single Emails');
}
Also i delete the #type line in the fields of the form to get a properly display in forum_notifications_subscription.module
Lines 103 to 110
$build['forum_notifications_subscription'] = [
'#type' => 'fieldset',
'#prefix' => "<div class='forum-topic-subscription-options'>",
'#suffix' => '</div>',
'#cache' => [
'tags' => ['forum_notification_frequency_list'],
],
];
Lines 128 to 136
$build['forum_notifications_subscription'] = [
'#type' => 'fieldset',
'#prefix' => "<div class='forum-main-subscription-options'>",
// '#prefix' => "<div>" . $description,
'#suffix' => '</div>',
'#cache' => [
'tags' => ['forum_notification_frequency_list'],
],
];
You can do the respective tests