Defect #24156 ยป 0001-Explicitly-remove-the-potential-global-scope-on-role.patch
app/models/group_builtin.rb | ||
---|---|---|
37 | 37 |
class << self |
38 | 38 |
def load_instance |
39 | 39 |
return nil if self == GroupBuiltin |
40 |
instance = order('id').first || create_instance |
|
40 |
instance = unscoped.order('id').first || create_instance
|
|
41 | 41 |
end |
42 | 42 | |
43 | 43 |
def create_instance |
44 | 44 |
raise 'The builtin group already exists.' if exists? |
45 |
instance = new |
|
45 |
instance = unscoped.new
|
|
46 | 46 |
instance.lastname = name |
47 | 47 |
instance.save :validate => false |
48 | 48 |
raise 'Unable to create builtin group.' if instance.new_record? |
app/models/role.rb | ||
---|---|---|
294 | 294 |
end |
295 | 295 | |
296 | 296 |
def self.find_or_create_system_role(builtin, name) |
297 |
role = where(:builtin => builtin).first |
|
297 |
role = unscoped.where(:builtin => builtin).first
|
|
298 | 298 |
if role.nil? |
299 |
role = create(:name => name) do |r| |
|
299 |
role = unscoped.create(:name => name) do |r|
|
|
300 | 300 |
r.builtin = builtin |
301 | 301 |
end |
302 | 302 |
raise "Unable to create the #{name} role (#{role.errors.full_messages.join(',')})." if role.new_record? |
app/models/user.rb | ||
---|---|---|
749 | 749 |
# Returns the anonymous user. If the anonymous user does not exist, it is created. There can be only |
750 | 750 |
# one anonymous user per database. |
751 | 751 |
def self.anonymous |
752 |
anonymous_user = AnonymousUser.first |
|
752 |
anonymous_user = AnonymousUser.unscoped.first
|
|
753 | 753 |
if anonymous_user.nil? |
754 |
anonymous_user = AnonymousUser.create(:lastname => 'Anonymous', :firstname => '', :login => '', :status => 0) |
|
754 |
anonymous_user = AnonymousUser.unscoped.create(:lastname => 'Anonymous', :firstname => '', :login => '', :status => 0)
|
|
755 | 755 |
raise 'Unable to create the anonymous user.' if anonymous_user.new_record? |
756 | 756 |
end |
757 | 757 |
anonymous_user |