From a8cc0711079e02c131eabcab9e453ec25088efbb Mon Sep 17 00:00:00 2001 From: Murphy Stroppa Date: Tue, 10 May 2016 16:47:55 -0400 Subject: [PATCH] Remove extra set_current_order calls Currently this is calling on almost every request in the front end. We want to push this to where it should be which is just when we sign in authentication systems. --- CHANGELOG.md | 12 ++++++++++++ .../controllers/spree/api/checkouts_controller.rb | 3 --- core/lib/spree/core/controller_helpers/order.rb | 2 -- frontend/app/controllers/spree/store_controller.rb | 2 -- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0776383d8df..330f3144c1f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ ## Solidus 2.4.0 (master, unreleased) +- Remove `set_current_order` calls in `Spree::Core::ControllerHelpers::Order` + [\#2185](https://github.com/solidusio/solidus/pull/2185) ([Murph33](https://github.com/murph33)) + + Previously a before filter added in + `core/lib/spree/core/controller_helpers/order.rb` would cause SQL queries to + be used on almost every request in the frontend. If you do not use Solidus + Auth you will need to hook into this helper and call `set_current_order` where + your user signs in. This merges incomplete orders a user has going with their + current cart. If you do use Solidus Auth you will need to make sure you use a + current enough version (>= v1.5.0) that includes this explicit call. This + addresses [\#1116](https://github.com/solidusio/solidus/issues/1116). + - Remove `ffaker` as a runtime dependency in production [\#2140](https://github.com/solidusio/solidus/pull/2140) ([cbrunsdon](https://github.com/cbrunsdon)) - Invalidate existing non store credit payments during checkout [2075](https://github.com/solidusio/solidus/pull/2075) ([tvdeyen](https://github.com/tvdeyen)) diff --git a/api/app/controllers/spree/api/checkouts_controller.rb b/api/app/controllers/spree/api/checkouts_controller.rb index 2048fb20ff9..0a52cc9a4f6 100644 --- a/api/app/controllers/spree/api/checkouts_controller.rb +++ b/api/app/controllers/spree/api/checkouts_controller.rb @@ -12,9 +12,6 @@ class CheckoutsController < Spree::Api::BaseController # TODO: Remove this after deprecated usage in #update is removed include Spree::Core::ControllerHelpers::PaymentParameters - # This before_action comes from Spree::Core::ControllerHelpers::Order - skip_before_action :set_current_order - def next authorize! :update, @order, order_token if !expected_total_ok?(params[:expected_total]) diff --git a/core/lib/spree/core/controller_helpers/order.rb b/core/lib/spree/core/controller_helpers/order.rb index 9910a6b00c6..cfb98b692d3 100644 --- a/core/lib/spree/core/controller_helpers/order.rb +++ b/core/lib/spree/core/controller_helpers/order.rb @@ -8,8 +8,6 @@ module Order include ControllerHelpers::Pricing included do - before_action :set_current_order - helper_method :current_order helper_method :simple_current_order end diff --git a/frontend/app/controllers/spree/store_controller.rb b/frontend/app/controllers/spree/store_controller.rb index 6dfa12b2bf1..8b391508d0d 100644 --- a/frontend/app/controllers/spree/store_controller.rb +++ b/frontend/app/controllers/spree/store_controller.rb @@ -3,8 +3,6 @@ class StoreController < Spree::BaseController include Spree::Core::ControllerHelpers::Pricing include Spree::Core::ControllerHelpers::Order - skip_before_action :set_current_order, only: :cart_link - def unauthorized render 'spree/shared/unauthorized', layout: Spree::Config[:layout], status: 401 end