wiki: fix titles with invalid space characters.
Fix wiki pages that have titles containing space characters.
This commit is contained in:
21
script/fixes/065_fix_invalid_wiki_page_titles.rb
Executable file
21
script/fixes/065_fix_invalid_wiki_page_titles.rb
Executable file
@@ -0,0 +1,21 @@
|
|||||||
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
|
require_relative "../../config/environment"
|
||||||
|
|
||||||
|
CurrentUser.user = User.system
|
||||||
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
|
|
||||||
|
# Fix wiki page titles containing invalid space characters.
|
||||||
|
WikiPage.transaction do
|
||||||
|
WikiPage.where("title ~ '\\s'").find_each do |wiki_page|
|
||||||
|
wiki_page.normalize_title
|
||||||
|
wiki_page.save!
|
||||||
|
# handle name conflicts
|
||||||
|
rescue ActiveRecord::RecordInvalid
|
||||||
|
wiki_page.normalize_title
|
||||||
|
wiki_page.title = "#{wiki_page.title}_#{wiki_page.id}"
|
||||||
|
wiki_page.save!
|
||||||
|
ensure
|
||||||
|
puts "wiki id=#{wiki_page.id} title=#{wiki_page.title}"
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user