From 4f1377405cc7b7317756a39ecff97dbf071680d9 Mon Sep 17 00:00:00 2001 From: r888888888 Date: Fri, 31 May 2013 15:15:24 -0700 Subject: [PATCH] fixes #1660 --- app/models/post.rb | 4 ++-- script/fixes/015.rb | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/models/post.rb b/app/models/post.rb index 8aa59f457..8fd537511 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -875,8 +875,8 @@ class Post < ActiveRecord::Base end module VersionMethods - def create_version - if new_record? || rating_changed? || source_changed? || parent_id_changed? || tag_string_changed? + def create_version(force = false) + if new_record? || rating_changed? || source_changed? || parent_id_changed? || tag_string_changed? || force CurrentUser.increment!(:post_update_count) versions.create( :rating => rating, diff --git a/script/fixes/015.rb b/script/fixes/015.rb index 0a4fa0de9..8be44fde9 100644 --- a/script/fixes/015.rb +++ b/script/fixes/015.rb @@ -15,3 +15,13 @@ ForumTopic.find_each do |topic| topic.update_column(:updater_id, last.creator_id) if topic.updater_id != last.creator_id topic.update_column(:updated_at, last.updated_at) if topic.updated_at != last.updated_at end + +admin = User.admins.first + +CurrentUser.scoped(admin, "127.0.0.1") do + Post.where("created_at >= ?", "2013-02-01").find_each do |post| + if post.tag_string != post.versions.last.tag_string + post.create_version(true) + end + end +end