@@ -141,15 +141,6 class WikiController < ApplicationController | |||||
141 | end |
|
141 | end | |
142 | content_params ||= {} |
|
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 | @content.comments = content_params[:comments] |
|
144 | @content.comments = content_params[:comments] | |
154 | @text = content_params[:text] |
|
145 | @text = content_params[:text] | |
155 | if params[:section].present? && Redmine::WikiFormatting.supports_section_edit? |
|
146 | if params[:section].present? && Redmine::WikiFormatting.supports_section_edit? | |
@@ -161,8 +152,8 class WikiController < ApplicationController | |||||
161 | @content.text = @text |
|
152 | @content.text = @text | |
162 | end |
|
153 | end | |
163 | @content.author = User.current |
|
154 | @content.author = User.current | |
164 | @page.content = @content |
|
155 | ||
165 | if @page.save |
|
156 | if @page.save_with_content | |
166 | attachments = Attachment.attach_files(@page, params[:attachments]) |
|
157 | attachments = Attachment.attach_files(@page, params[:attachments]) | |
167 | render_attachment_warning_if_needed(@page) |
|
158 | render_attachment_warning_if_needed(@page) | |
168 | call_hook(:controller_wiki_edit_after_save, { :params => params, :page => @page}) |
|
159 | call_hook(:controller_wiki_edit_after_save, { :params => params, :page => @page}) |
@@ -173,6 +173,21 class WikiPage < ActiveRecord::Base | |||||
173 | self.parent = parent_page |
|
173 | self.parent = parent_page | |
174 | end |
|
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 | protected |
|
191 | protected | |
177 |
|
192 | |||
178 | def validate_parent_title |
|
193 | def validate_parent_title |
General Comments 0
You need to be logged in to leave comments.
Login now