Skip to content

Commit

Permalink
Revert "Preload related objects in Alchemy::PagesController"
Browse files Browse the repository at this point in the history
Pages make use of fragment caching and we cannot know which element is cached.

Therefore we cannot know what to eager load.

Refs AlchemyCMS#2468

This reverts commit d556574.
  • Loading branch information
tvdeyen committed May 11, 2023
1 parent 7cd3846 commit 1a8edac
Showing 1 changed file with 5 additions and 19 deletions.
24 changes: 5 additions & 19 deletions app/controllers/alchemy/pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,7 @@ def locale_prefix_not_allowed?
# If no index page and no admin users are present we show the "Welcome to Alchemy" page.
#
def load_index_page
@page ||= begin
Alchemy::Page.
contentpages.
language_roots.
where(language: Language.current).
includes(page_includes).
first
end
@page ||= Language.current_root_page
render template: "alchemy/welcome", layout: false if signup_required?
end

Expand All @@ -127,13 +120,10 @@ def load_index_page
def load_page
page_not_found! unless Language.current

@page ||= begin
Alchemy::Page.
contentpages.
where(language: Language.current).
includes(page_includes).
find_by(urlname: params[:urlname])
end
@page ||= Language.current.pages.contentpages.find_by(
urlname: params[:urlname],
language_code: params[:locale] || Language.current.code,
)
end

def enforce_locale
Expand Down Expand Up @@ -244,9 +234,5 @@ def must_not_cache?
def page_not_found!
not_found_error!("Alchemy::Page not found \"#{request.fullpath}\"")
end

def page_includes
Alchemy::EagerLoading.page_includes(version: :public_version)
end
end
end

0 comments on commit 1a8edac

Please sign in to comment.