Merge pull request #3501 from BrokenEagle/fix-2974

Fix erroneous updates to wiki page when nothing changes
This commit is contained in:
Albert Yi
2018-01-15 10:52:36 -08:00
committed by GitHub
2 changed files with 10 additions and 4 deletions

View File

@@ -382,7 +382,7 @@ class Artist < ApplicationRecord
if @notes.present? if @notes.present?
create_wiki_page(body: @notes, title: name) create_wiki_page(body: @notes, title: name)
end end
elsif wiki_page.body != @notes || wiki_page.title != name elsif (!@notes.nil? && (wiki_page.body != @notes)) || wiki_page.title != name
# if anything changed, we need to update the wiki page # if anything changed, we need to update the wiki page
wiki_page.body = @notes unless @notes.nil? wiki_page.body = @notes unless @notes.nil?
wiki_page.title = name wiki_page.title = name

View File

@@ -190,6 +190,10 @@ class WikiPage < ApplicationRecord
title.tr("_", " ") title.tr("_", " ")
end end
def wiki_page_changed?
title_changed? || body_changed? || is_locked_changed? || is_deleted_changed? || other_names_changed?
end
def merge_version def merge_version
prev = versions.last prev = versions.last
prev.update_attributes( prev.update_attributes(
@@ -219,7 +223,7 @@ class WikiPage < ApplicationRecord
end end
def create_version def create_version
if title_changed? || body_changed? || is_locked_changed? || is_deleted_changed? || other_names_changed? if wiki_page_changed?
if merge_version? if merge_version?
merge_version merge_version
else else
@@ -235,9 +239,11 @@ class WikiPage < ApplicationRecord
def initialize_creator def initialize_creator
self.creator_id = CurrentUser.user.id self.creator_id = CurrentUser.user.id
end end
def initialize_updater def initialize_updater
self.updater_id = CurrentUser.user.id if wiki_page_changed?
self.updater_id = CurrentUser.user.id
end
end end
def post_set def post_set