diff app/models/wiki_page.rb @ 1517:dffacf8a6908 redmine-2.5

Update to Redmine SVN revision 13367 on 2.5-stable branch
author Chris Cannam
date Tue, 09 Sep 2014 09:29:00 +0100
parents e248c7af89ec
children
line wrap: on
line diff
--- a/app/models/wiki_page.rb	Tue Sep 09 09:28:31 2014 +0100
+++ b/app/models/wiki_page.rb	Tue Sep 09 09:29:00 2014 +0100
@@ -82,12 +82,12 @@
     # Manage redirects if the title has changed
     if !@previous_title.blank? && (@previous_title != title) && !new_record?
       # Update redirects that point to the old title
-      wiki.redirects.find_all_by_redirects_to(@previous_title).each do |r|
+      wiki.redirects.where(:redirects_to => @previous_title).each do |r|
         r.redirects_to = title
         r.title == r.redirects_to ? r.destroy : r.save
       end
       # Remove redirects for the new title
-      wiki.redirects.find_all_by_title(title).each(&:destroy)
+      wiki.redirects.where(:title => title).each(&:destroy)
       # Create a redirect to the new title
       wiki.redirects << WikiRedirect.new(:title => @previous_title, :redirects_to => title) unless redirect_existing_links == "0"
       @previous_title = nil
@@ -96,7 +96,7 @@
 
   def remove_redirects
     # Remove redirects to this page
-    wiki.redirects.find_all_by_redirects_to(title).each(&:destroy)
+    wiki.redirects.where(:redirects_to => title).each(&:destroy)
   end
 
   def pretty_title
@@ -104,9 +104,11 @@
   end
 
   def content_for_version(version=nil)
-    result = content.versions.find_by_version(version.to_i) if version
-    result ||= content
-    result
+    if content
+      result = content.versions.find_by_version(version.to_i) if version
+      result ||= content
+      result
+    end
   end
 
   def diff(version_to=nil, version_from=nil)