Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Right now we have this in the code in the comment_notify_form_user_form_alter()
method in the comment_notify.module file:
$user = $form_state->getFormObject()->getEntity();
$notify_settings = $user->id() ? comment_notify_get_user_notification_setting($user->id()) : comment_notify_get_default_notification_setting();
And in comment_notify_get_user_notification_setting()
we have:
} else {
$setting = db_select('comment_notify_user_settings', 'cnus')
->fields('cnus')
->condition('uid', $uid)
->execute()
->fetchObject();
if (!$setting) {
return NULL;
}
else {
$users[$uid] = $setting;
}
The problem is when the user hasn't a row in the comment_notify_user_settings
table, this makes the function return NULL and $notify_settings
is used later to determine the default values of the comment settngis fields.
I attach a small patch in my next comment and later I will try to provide a test.
Comment | File | Size | Author |
---|---|---|---|
#3 | 2850935-bug-user-profile-3.patch | 779 bytes | gnuget |
| |||
#3 | 2850935-interdiff-2-3.txt | 1.17 KB | gnuget |
#2 | 2850935-bug-user-profile.patch | 419 bytes | gnuget |
|
Comments
Comment #2
gnugetPatch attached.
Comment #3
gnugetToday I found an error with my first approach.
It seems to the
NULL
value oncomment_notify_get_user_notification_setting()
is expected in another part of the module so I revert that change and did the change directly on thecomment_notify_form_user_form_alter()
function.patch attached.
Comment #4
DamienMcKennaComment #5
themic8 CreditAttribution: themic8 at Trail 9 commentedHello,
Right now if I create or update a user I get this error:
I have also reviewed this table: comment_notify_user_settings which doesn't have any entries in it.
I'm still looking into it but wanted to put this out there.
Comment #7
gregglesLooks like a reasonable solution to me - thanks!