This commit is contained in:
Toks
2013-07-31 19:57:15 -04:00
2 changed files with 20 additions and 16 deletions

View File

@@ -127,18 +127,20 @@ class TagAlias < ActiveRecord::Base
def update_posts def update_posts
CurrentUser.without_safe_mode do CurrentUser.without_safe_mode do
Post.raw_tag_match(antecedent_name).find_each do |post| Post.without_timeout do
escaped_antecedent_name = Regexp.escape(antecedent_name) Post.raw_tag_match(antecedent_name).find_each do |post|
fixed_tags = post.tag_string.sub(/(?:\A| )#{escaped_antecedent_name}(?:\Z| )/, " #{consequent_name} ").strip escaped_antecedent_name = Regexp.escape(antecedent_name)
CurrentUser.scoped(creator, creator_ip_addr) do fixed_tags = post.tag_string.sub(/(?:\A| )#{escaped_antecedent_name}(?:\Z| )/, " #{consequent_name} ").strip
post.update_attributes( CurrentUser.scoped(creator, creator_ip_addr) do
:tag_string => fixed_tags post.update_attributes(
) :tag_string => fixed_tags
)
end
end end
end
antecedent_tag.fix_post_count if antecedent_tag antecedent_tag.fix_post_count if antecedent_tag
consequent_tag.fix_post_count if consequent_tag consequent_tag.fix_post_count if consequent_tag
end
end end
end end

View File

@@ -127,12 +127,14 @@ class TagImplication < ActiveRecord::Base
def update_posts def update_posts
CurrentUser.without_safe_mode do CurrentUser.without_safe_mode do
Post.raw_tag_match(antecedent_name).find_each do |post| Post.without_timeout do
fixed_tags = "#{post.tag_string} #{descendant_names}".strip Post.raw_tag_match(antecedent_name).find_each do |post|
CurrentUser.scoped(creator, creator_ip_addr) do fixed_tags = "#{post.tag_string} #{descendant_names}".strip
post.update_attributes( CurrentUser.scoped(creator, creator_ip_addr) do
:tag_string => fixed_tags post.update_attributes(
) :tag_string => fixed_tags
)
end
end end
end end
end end