@@ -141,15 +141,6 class WikiController < ApplicationController | |||
|
141 | 141 | end |
|
142 | 142 | content_params ||= {} |
|
143 | 143 | |
|
144 | if !@page.new_record? && content_params.present? && @content.text == content_params[:text] | |
|
145 | attachments = Attachment.attach_files(@page, params[:attachments]) | |
|
146 | render_attachment_warning_if_needed(@page) | |
|
147 | # don't save content if text wasn't changed | |
|
148 | @page.save | |
|
149 | redirect_to :action => 'show', :project_id => @project, :id => @page.title | |
|
150 | return | |
|
151 | end | |
|
152 | ||
|
153 | 144 | @content.comments = content_params[:comments] |
|
154 | 145 | @text = content_params[:text] |
|
155 | 146 | if params[:section].present? && Redmine::WikiFormatting.supports_section_edit? |
@@ -161,8 +152,8 class WikiController < ApplicationController | |||
|
161 | 152 | @content.text = @text |
|
162 | 153 | end |
|
163 | 154 | @content.author = User.current |
|
164 | @page.content = @content | |
|
165 | if @page.save | |
|
155 | ||
|
156 | if @page.save_with_content | |
|
166 | 157 | attachments = Attachment.attach_files(@page, params[:attachments]) |
|
167 | 158 | render_attachment_warning_if_needed(@page) |
|
168 | 159 | call_hook(:controller_wiki_edit_after_save, { :params => params, :page => @page}) |
@@ -173,6 +173,21 class WikiPage < ActiveRecord::Base | |||
|
173 | 173 | self.parent = parent_page |
|
174 | 174 | end |
|
175 | 175 | |
|
176 | # Saves the page and its content if text was changed | |
|
177 | def save_with_content | |
|
178 | ret = nil | |
|
179 | transaction do | |
|
180 | if new_record? | |
|
181 | # Rails automatically saves associated content | |
|
182 | ret = save | |
|
183 | else | |
|
184 | ret = save && (content.text_changed? ? content.save : true) | |
|
185 | end | |
|
186 | raise ActiveRecord::Rollback unless ret | |
|
187 | end | |
|
188 | ret | |
|
189 | end | |
|
190 | ||
|
176 | 191 | protected |
|
177 | 192 | |
|
178 | 193 | def validate_parent_title |
General Comments 0
You need to be logged in to leave comments.
Login now