Notification claims X users for approval, but none are found

This looks like a bug, but I can’t see how to reproduce it.

I get a notification PM that says:

But when I click the review link, there are no pending users. In /admin/users I see some users that have not validated their email addresses.

I can’t tell if the notification is producing the wrong number, or if there somehow exist users waiting approval that are not showing up when searching for them, or if somehow users who haven’t validated email are getting counted as pending for notifications but not for approval.

3 Likes

not to be Ms Obvious but is allow_new_registrations unchecked by chance? clearly you have the must_approve_users setting enabled and i’m not sure how that is affected if registration is disabled. :thinking: i would think the registration setting would override any account creation though and disable it. no that makes no sense either…

It’s almost certainly something obvious, so I welcome your help.

Yes, both of those are checked. Some people are getting registered and approved. It’s just that the number claimed to be waiting does not match the number claimed in the notification. It told me 5, and there had been only 2 in the past several days.

1 Like

very odd indeed. kinda sounds like something in the user registration is being rejected after the approval request is sent (counted) for review…

2 Likes

Are there reviewed users when you show all reviewed items, or maybe from the staff logs? :person_shrugging:

I often got PMs/reminds of reviewable items that are already reviewed, so nothing shows up.

I asssumed that the issue was that someone else approved the users before I (or the site owner) got to them, but I can’t make the numbers add up that way).

Can a user delete their account before their registration is approved?

Maybe? I don’t think so, as they’d need to log in to do that and they can’t log in until they are approved (but I didn’t check the code or anything like that)

I found this topic while searching before filing a bug report, so adding to it.

TL;DR the query for the notification is wrong because it counts rejected users as well.

Notification: 16 users waiting for approval, click the link, see only 2.

The query used for the notification is this

puts AdminUserIndexQuery.new(query: "pending", stats: false).find_users_query.to_sql

SELECT "users".* FROM "users" 
WHERE (suspended_till IS NULL OR suspended_till <= '2023-11-13 11:05:23.225614') 
AND "users"."approved" = FALSE 
AND "users"."active" = TRUE 
ORDER BY users.created_at DESC,users.username

which, in my case, gives me 16 users

[4479, 4472, 4456, 4446, 4443, 4430, 4302, 4291, 4206, 4199, 4178, 4168, 4131, 4061, 3677, 3642]

Throwing these ids into the Reviewables queue gives me 2 users that actually need to be approved (status 0) and 14 users that have already been rejected (status 2)

ReviewableUser.where(type: 'ReviewableUser')
  .where(target_id: ids)
  .pluck(:target_id, :status)

[[3642, 2], [3677, 2], [4061, 2], [4131, 2], [4168, 2], 
[4178, 2], [4199, 2], [4206, 2], [4291, 2], [4302, 2], 
[4430, 2], [4443, 2], [4446, 2], [4456, 2], [4472, 0], [4479, 0]]
2 Likes