From 3235f2c477c86a7ecc4e96e600a65fc789914593 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Tue, 19 Aug 2014 13:46:40 -0400 Subject: [PATCH] FIX: Don't try and delete inactive admins, rare as they may be. --- app/models/user.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index 1ec99c667a7..0aa1e5f18a8 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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