Fix #4629: Tag renames/aliases should also modify pool descriptions.

This commit is contained in:
evazion
2022-01-15 20:30:51 -06:00
parent 33103f6dc4
commit 5bec0aa147
4 changed files with 19 additions and 7 deletions

View File

@@ -139,9 +139,10 @@ class TagMover
User.rewrite_blacklists!(old_tag.name, new_tag.name)
end
# Update any wiki pages linking to the old tag, to link to the new tag.
# Update any wiki pages or pools linking to the old tag, to link to the new tag.
def rewrite_wiki_links!
WikiPage.rewrite_wiki_links!(old_tag.name, new_tag.name)
Pool.rewrite_wiki_links!(old_tag.name, new_tag.name)
end
# Merge two artist entries, copying everything from the old entry to the new

View File

@@ -254,4 +254,10 @@ class Pool < ApplicationRecord
errors.add(:name, "cannot contain only digits")
end
end
def self.rewrite_wiki_links!(old_name, new_name)
Pool.linked_to(old_name).each do |pool|
pool.lock!.update!(description: DText.rewrite_wiki_links(pool.description, old_name, new_name))
end
end
end

View File

@@ -212,12 +212,8 @@ class WikiPage < ApplicationRecord
end
def self.rewrite_wiki_links!(old_name, new_name)
broken_wikis = WikiPage.linked_to(old_name)
broken_wikis.each do |wiki|
wiki.lock!
wiki.body = DText.rewrite_wiki_links(wiki.body, old_name, new_name)
wiki.save!
WikiPage.linked_to(old_name).each do |wiki|
wiki.lock!.update!(body: DText.rewrite_wiki_links(wiki.body, old_name, new_name))
end
end