From 33f8ad000c79f361eb3f885ee1c078d44991686c Mon Sep 17 00:00:00 2001 From: r888888888 Date: Wed, 31 Jul 2013 16:56:32 -0700 Subject: [PATCH] potential fix for #1800 --- app/models/tag_alias.rb | 22 ++++++++++++---------- app/models/tag_implication.rb | 14 ++++++++------ 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/app/models/tag_alias.rb b/app/models/tag_alias.rb index c4052aceb..79ff27bc4 100644 --- a/app/models/tag_alias.rb +++ b/app/models/tag_alias.rb @@ -127,18 +127,20 @@ class TagAlias < ActiveRecord::Base def update_posts CurrentUser.without_safe_mode do - Post.raw_tag_match(antecedent_name).find_each do |post| - escaped_antecedent_name = Regexp.escape(antecedent_name) - fixed_tags = post.tag_string.sub(/(?:\A| )#{escaped_antecedent_name}(?:\Z| )/, " #{consequent_name} ").strip - CurrentUser.scoped(creator, creator_ip_addr) do - post.update_attributes( - :tag_string => fixed_tags - ) + Post.without_timeout do + Post.raw_tag_match(antecedent_name).find_each do |post| + escaped_antecedent_name = Regexp.escape(antecedent_name) + fixed_tags = post.tag_string.sub(/(?:\A| )#{escaped_antecedent_name}(?:\Z| )/, " #{consequent_name} ").strip + CurrentUser.scoped(creator, creator_ip_addr) do + post.update_attributes( + :tag_string => fixed_tags + ) + end end - end - antecedent_tag.fix_post_count if antecedent_tag - consequent_tag.fix_post_count if consequent_tag + antecedent_tag.fix_post_count if antecedent_tag + consequent_tag.fix_post_count if consequent_tag + end end end diff --git a/app/models/tag_implication.rb b/app/models/tag_implication.rb index a0910f7c0..2ec785693 100644 --- a/app/models/tag_implication.rb +++ b/app/models/tag_implication.rb @@ -127,12 +127,14 @@ class TagImplication < ActiveRecord::Base def update_posts CurrentUser.without_safe_mode do - Post.raw_tag_match(antecedent_name).find_each do |post| - fixed_tags = "#{post.tag_string} #{descendant_names}".strip - CurrentUser.scoped(creator, creator_ip_addr) do - post.update_attributes( - :tag_string => fixed_tags - ) + Post.without_timeout do + Post.raw_tag_match(antecedent_name).find_each do |post| + fixed_tags = "#{post.tag_string} #{descendant_names}".strip + CurrentUser.scoped(creator, creator_ip_addr) do + post.update_attributes( + :tag_string => fixed_tags + ) + end end end end