Skip to content

Commit

Permalink
Remove with_lock from save_permalink
Browse files Browse the repository at this point in the history
This lock was well-intentionned, but doesn't do anything to reduce the
likelyhood of a duplicate permalink.
  • Loading branch information
jhawthorn committed Nov 1, 2017
1 parent 4b21640 commit 6e39f57
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions core/lib/spree/core/permalinks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,17 @@ def generate_permalink
end

def save_permalink(permalink_value = to_param)
with_lock do
permalink_value ||= generate_permalink
permalink_field = self.class.permalink_field
permalink_value ||= generate_permalink
permalink_field = self.class.permalink_field

loop do
other = self.class.where(permalink_field => permalink_value)
break unless other.exists?
loop do
other = self.class.where(permalink_field => permalink_value)
break unless other.exists?

# Try again with a new value
permalink_value = generate_permalink
end
write_attribute(permalink_field, permalink_value)
# Try again with a new value
permalink_value = generate_permalink
end
write_attribute(permalink_field, permalink_value)
end
end
end
Expand Down

0 comments on commit 6e39f57

Please sign in to comment.