diff --git a/app/models/page_revision.rb b/app/models/page_revision.rb index 4b29ac97..0c94c372 100644 --- a/app/models/page_revision.rb +++ b/app/models/page_revision.rb @@ -209,10 +209,12 @@ def make_real() container = self.revision_container PageRevision.transaction do - real_rev = container.page_revisions.find(:all,:conditions => [ 'revision_type="real" AND revision=? AND language=? AND id != ?', self.revision,self.language,self.id] ) - real_rev.each do |rev| - rev.update_attributes(:revision_type => 'old' ) - DomainFileInstance.clear_targets('PageParagraph',rev.page_paragraph_ids) + real_rev = container.page_revisions.find(:all,:conditions => [ 'revision_type="real" AND revision=? AND language=? AND id != ?', self.revision,self.language,self.id] ) if container + if real_rev + real_rev.each do |rev| + rev.update_attributes(:revision_type => 'old' ) + DomainFileInstance.clear_targets('PageParagraph',rev.page_paragraph_ids) + end end self.update_attributes( :created_at => Time.now, :revision_type => 'real') diff --git a/lib/tasks/restore.rake b/lib/tasks/restore.rake index 20e0d914..b857ebdd 100644 --- a/lib/tasks/restore.rake +++ b/lib/tasks/restore.rake @@ -92,6 +92,10 @@ namespace "cms" do # Delete any rendered parts DomainModel.connection.execute("DELETE FROM site_template_rendered_parts WHERE 1") + + # Changed to local file storage + DomainFile.update_all("processor='local'","file_type != 'fld' AND processor != 'local'") + begin # Resave update any file store DomainFileInstance.rebuild_all @@ -123,14 +127,18 @@ namespace "cms" do DomainFile.update_all "server_hash = '#{server_hash}'", 'file_type != "fld" and server_hash IS NULL' end + PageRevision.find(:all,:conditions => { :active => 1, :revision_type => 'real' }, :include => :page_paragraphs).each { |rev| rev.page_paragraphs.map(&:save); rev.make_real } + + # Clear out the cache for the domain + begin - SiteTemplate.find(:all).map(&:save) SiteFeature.find(:all).map(&:save) + SiteTemplate.find(:all).map(&:save) rescue Exception => e puts("There was a problem resaving site templates and features - continuing import anyway") end - # Clear out the cache for the domain + # Resave paragraphs to fix links DataCache.expire_domain(dmn.database) # Make the database active again