FIX: Don't try and delete inactive admins, rare as they may be.

This commit is contained in:
Robin Ward 2014-08-19 13:46:40 -04:00
parent 2672857aee
commit 3235f2c477
1 changed files with 6 additions and 1 deletions

View File

@ -727,11 +727,16 @@ class User < ActiveRecord::Base
.joins('INNER JOIN user_stats AS us ON us.user_id = users.id')
.where("created_at < ?", SiteSetting.purge_inactive_users_grace_period_days.days.ago)
.where('us.post_count = 0')
.where('NOT admin AND NOT moderator')
.limit(100)
destroyer = UserDestroyer.new(Discourse.system_user)
to_destroy.each do |u|
destroyer.destroy(u)
begin
destroyer.destroy(u)
rescue Discourse::InvalidAccess
# if for some reason the user can't be deleted, continue on to the next one
end
end
end