Commit 043b4c321c704d686fef80f1d54e83e7c19397b9
1 parent
7798223b
Exists in
master
and in
29 other branches
Fixing memory overload on blog with native translation feature
(ActionItem2471)
Showing
1 changed file
with
9 additions
and
3 deletions
Show diff stats
app/controllers/public/content_viewer_controller.rb
| ... | ... | @@ -79,11 +79,17 @@ class ContentViewerController < ApplicationController |
| 79 | 79 | @page.posts |
| 80 | 80 | end |
| 81 | 81 | |
| 82 | - if @page.blog? && @page.display_posts_in_current_language? | |
| 83 | - posts = posts.native_translations.all(Article.display_filter(user, profile)).map{ |p| p.get_translation_to(FastGettext.locale) }.compact | |
| 84 | - end | |
| 82 | + #FIXME Need to run this before the pagination because this version of | |
| 83 | + # will_paginate returns a will_paginate collection instead of a | |
| 84 | + # relation. | |
| 85 | + blog_with_translation = @page.blog? && @page.display_posts_in_current_language? | |
| 86 | + posts = posts.native_translations if blog_with_translation | |
| 85 | 87 | |
| 86 | 88 | @posts = posts.paginate({ :page => params[:npage], :per_page => @page.posts_per_page }.merge(Article.display_filter(user, profile))) |
| 89 | + | |
| 90 | + if blog_with_translation | |
| 91 | + @posts.replace @posts.map{ |p| p.get_translation_to(FastGettext.locale) }.compact | |
| 92 | + end | |
| 87 | 93 | end |
| 88 | 94 | |
| 89 | 95 | if @page.folder? && @page.gallery? | ... | ... |