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.
A new user is created in Drupal, but not yet approved, still gets notifications from this module if they've been automatically subscribed to a custom subscription.
Comment | File | Size | Author |
---|---|---|---|
#10 | blocked-user-fix-663186-10.patch | 2.19 KB | pagaille |
Comments
Comment #1
pimousse98 CreditAttribution: pimousse98 commentedsubscribing
seems to apply to all blocked users, whether or not it is from the initial creation or not.
Would there be a way to set all of the user's notifications to "inactive" when a user is blocked?
Comment #2
gregglesAgreed - restating title to match problem.
Comment #3
Jose Reyero CreditAttribution: Jose Reyero commentedSubscriptions should get blocked, that's done on notifications_user().
Anyway, I agree we may need an extra check when actually sending the notification.
Comment #4
Jose Reyero CreditAttribution: Jose Reyero commentedFixed for 4.x
http://drupalcode.org/viewvc/drupal/contributions/modules/notifications/...
Comment #5
capellicWhere in the code (6.x-4.x-beta6 and higher) are you checking for the user's status from the user table? I'd like to backport this code into my 2.3 version.
Also, I get setting any notifications that are in the queue to status = 0 and then I see in 4.x that their status will be turned back on should the user's status become active. Is there any time when Notifications will flush stale notifications that have status = 0? Seems like a lot of dead weight to be carrying around.
Comment #6
capellicI was able to fix this by adding one line of code to notifications_process_rows in notifications.cron.inc.
Was:
Now:
You'll noticed the only difference is that I added a join on the users table.
Comment #7
capellicThere was an error with the query that I suggested in #6 above. When the queue was being processed, the following error would occur:
The query has been corrected and is now:
I also discovered a problem when trying to send a broadcast email to OG members. It required that I do a string replace on the "where" conditions to avoid ambiguity on uid. Just before the query code above, I have added the following line.
Comment #8
valante CreditAttribution: valante commentedPlease add the fix to the D7 version as well.
Comment #9
Pepper CreditAttribution: Pepper commentedChanging the last line to users.uid doesn't fix the error. I'm still getting
Column 'uid' in where clause is ambiguous query: SELECT * FROM notifications_queue JOIN users ON notifications_queue.uid = users.uid AND users.status = 1
Also just where exactly was the str_replace going?
Comment #10
pagaille CreditAttribution: pagaille as a volunteer commentedAttached is a patch for D7.
hook_user_update()
was not being called, so when a user's status changed, their subscription status was not being updated. Patch fixes this. It does not check users' status when sending notifications, so after applying patch you will want to check your db for subscriptions that are still active for users who are blocked. DB query to fix existing subscriptions isUPDATE notifications_subscription SET STATUS = 0 WHERE uid IN( SELECT uid FROM users WHERE STATUS = 0 )
.