Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Add deprecation warnings to legacy functionality (Spree 5.5) (#13599)
Damian Legawiec180736c2063c
diff --git a/backend/engines/core/app/models/spree/ability.rb b/backend/engines/core/app/models/spree/ability.rbindex 2934bd8ff4..d9d52970f0 100644--- a/backend/engines/core/app/models/spree/ability.rb+++ b/backend/engines/core/app/models/spree/ability.rb@@ -30,11 +30,21 @@ module Spree# modify the default +Ability+ of an application. The +ability+ argument must be a class that includes# the +CanCan::Ability+ module. The registered ability should behave properly as a stand-alone class# and therefore should be easy to test in isolation.+ # @deprecated Use Spree::PermissionSets instead. Will be removed in Spree 5.5.def self.register_ability(ability)+ Spree::Deprecation.warn(+ 'Spree::Ability.register_ability is deprecated and will be removed in Spree 5.5. ' \+ 'Please use Spree::PermissionSets instead. See Spree::PermissionSets::Base for details.'+ )abilities.add(ability)end+ # @deprecated Use Spree::PermissionSets instead. Will be removed in Spree 5.5.def self.remove_ability(ability)+ Spree::Deprecation.warn(+ 'Spree::Ability.remove_ability is deprecated and will be removed in Spree 5.5. ' \+ 'Please use Spree::PermissionSets instead. See Spree::PermissionSets::Base for details.'+ )abilities.delete(ability)enddiff --git a/backend/engines/core/app/models/spree/store.rb b/backend/engines/core/app/models/spree/store.rbindex 1860a25aa0..4503627c65 100644--- a/backend/engines/core/app/models/spree/store.rb+++ b/backend/engines/core/app/models/spree/store.rb@@ -204,14 +204,17 @@ module Spreeendend- # FIXME: we need to drop `or_initialize` in v5- # this behaviour is very buggy and unpredictable+ # @deprecated The or_initialize behavior will be removed in Spree 5.5.def self.defaultRails.cache.fetch('default_store') do# workaround for Mobility bug with first_or_initializeif where(default: true).any?where(default: true).firstelse+ Spree::Deprecation.warn(+ 'Spree::Store.default returning a new unpersisted store when no default store exists is deprecated ' \+ 'and will be removed in Spree 5.5. Please ensure a default store is created before calling Store.default.'+ )new(default: true)endenddiff --git a/backend/engines/core/app/models/spree/taxon.rb b/backend/engines/core/app/models/spree/taxon.rbindex f8862f4d28..11869fbce5 100644--- a/backend/engines/core/app/models/spree/taxon.rb+++ b/backend/engines/core/app/models/spree/taxon.rb@@ -38,7 +38,8 @@ module Spreehas_one :store, through: :taxonomyhas_many :classifications, -> { order(:position) }, dependent: :destroy_async, inverse_of: :taxonhas_many :products, through: :classifications- has_one :icon, as: :viewable, dependent: :destroy, class_name: 'Spree::TaxonImage' # TODO: remove this as this is deprecated+ # @deprecated Use Spree::Taxon#image (Active Storage) instead. Will be removed in Spree 5.5.+ has_one :icon, as: :viewable, dependent: :destroy, class_name: 'Spree::TaxonImage'has_many :prototype_taxons, class_name: 'Spree::PrototypeTaxon', dependent: :destroyhas_many :prototypes, through: :prototype_taxons, class_name: 'Spree::Prototype'diff --git a/backend/engines/core/app/models/spree/taxon_image.rb b/backend/engines/core/app/models/spree/taxon_image.rbindex 95e04c2ff3..1153ec7f23 100644--- a/backend/engines/core/app/models/spree/taxon_image.rb+++ b/backend/engines/core/app/models/spree/taxon_image.rb@@ -1,9 +1,17 @@module Spree+ # @deprecated Use Spree::Taxon#image (Active Storage) instead. Will be removed in Spree 5.5.class TaxonImage < Assetinclude Spree::TaxonImage::Configuration::ActiveStorageinclude Rails.application.routes.url_helpersinclude Spree::ImageMethods+ after_initialize do+ Spree::Deprecation.warn(+ 'Spree::TaxonImage is deprecated and will be removed in Spree 5.5. ' \+ 'Please use Spree::Taxon#image (Active Storage) instead.'+ )+ end+def stylesself.class.styles.map do |_, size|width, height = size[/(\d+)x(\d+)/].split('x').map(&:to_i)diff --git a/backend/engines/core/lib/spree/webhooks.rb b/backend/engines/core/lib/spree/webhooks.rbindex 639219cfbc..21f163c9c5 100644--- a/backend/engines/core/lib/spree/webhooks.rb+++ b/backend/engines/core/lib/spree/webhooks.rb@@ -1,7 +1,7 @@module Spreemodule Webhooksdef self.disable_webhooks- Spree::Deprecation.warn('Spree::Webhooks.disable_webhooks is deprecated. Use Spree::LegacyWebhooks.disable_webhooks instead.')+ Spree::Deprecation.warn('Spree::Webhooks.disable_webhooks is deprecated and will be removed in Spree 5.5. Use Spree::LegacyWebhooks.disable_webhooks instead.')prev_value = disabled?RequestStore.store[:disable_spree_legacy_webhooks] = trueyield@@ -10,12 +10,12 @@ module Spreeenddef self.disabled?- Spree::Deprecation.warn('Spree::Webhooks.disabled? is deprecated. Use Spree::LegacyWebhooks.disabled? instead.')+ Spree::Deprecation.warn('Spree::Webhooks.disabled? is deprecated and will be removed in Spree 5.5. Use Spree::LegacyWebhooks.disabled? instead.')RequestStore.fetch(:disable_spree_legacy_webhooks) { false }enddef self.disabled=(value)- Spree::Deprecation.warn('Spree::Webhooks.disabled= is deprecated. Use Spree::LegacyWebhooks.disabled= instead.')+ Spree::Deprecation.warn('Spree::Webhooks.disabled= is deprecated and will be removed in Spree 5.5. Use Spree::LegacyWebhooks.disabled= instead.')RequestStore.store[:disable_spree_legacy_webhooks] = valueendend