maintenance: fix undefined current user exception.
Possible fix for this exception that happens in production for unclear
reasons:
NoMethodError: undefined method `is_admin?' for nil:NilClass
…oru/releases/20200805193154/app/policies/tag_policy.rb: 3:in `can_change_category?'
…www/danbooru/releases/20200805193154/app/models/tag.rb: 216:in `find_or_create_by_name'
…www/danbooru/releases/20200805193154/app/models/tag.rb: 193:in `block in create_for_list'
…www/danbooru/releases/20200805193154/app/models/tag.rb: 193:in `map'
…www/danbooru/releases/20200805193154/app/models/tag.rb: 193:in `create_for_list'
…ww/danbooru/releases/20200805193154/app/models/post.rb: 463:in `normalize_tags'
This commit is contained in:
@@ -35,8 +35,12 @@ module DanbooruMaintenance
|
||||
|
||||
def safely(&block)
|
||||
ActiveRecord::Base.connection.execute("set statement_timeout = 0")
|
||||
yield
|
||||
|
||||
CurrentUser.scoped(User.system, "127.0.0.1") do
|
||||
yield
|
||||
end
|
||||
rescue StandardError => exception
|
||||
DanbooruLogger.log(exception)
|
||||
raise exception if Rails.env.test?
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user