Removing Unconfirmed Users - Cron job issues

Re: Removing Unconfirmed Users - Cron job issues

by Todd Kurth -
Number of replies: 1

So I've made changes and still the account exists. I've set it for 1 day or 2 days, nothing is removed. The column in the database does not show as being marked deleted either. The cron job lists it is running a query to remove unconfirmed accounts. I'm baffled. I didn't see anything inside of any logs, though I'll be honest not sure if I was looking in the correct places.

In reply to Todd Kurth

Re: Removing Unconfirmed Users - Cron job issues

by Carles Bellver -

We have recently noticed this same problem: unconfirmed users are not being deleted by the cron task when it is executed. Our database shows more than one hundred users with confirmed = 0, deleted = 0 since our last upgrade from Moodle 2.7.

We have checked the code in lib/classes/task/delete_unconfirmed_users_task.php and this is the SQL query that retrieves the users to be deleted:

$rs = $DB->get_recordset_sql ("SELECT * FROM {user} WHERE confirmed = 0 AND firstaccess > 0 AND firstaccess < ? AND deleted = 0", array($cuttime));

($cuttime is current time - deleteunconfirmed threshold, 7 days by default.)

But the problem is that these users have firstaccess = 0 in DB, because login/signup.php sets $user->firstaccess = 0 when the account is created, so that the AND condition is never matched. And this didn't happen before upgrading because we have found that in Moodle 2.7 login/signup.php set $user->firstaccess = time(), i. e. account creation time, not zero.

So we think we have a bug and I have filed one in the Tracker. Could you please have a look there and vote?

[MDL-54106] Delete unconfirmed users not working because firstaccess == 0