You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wanted to create this issue to see if these deprecation warnings are known/expected on Spree.
Context
I first created a draft PR (here) to see how removing alias_attribute :contact_email, :customer_support_email on Spree::Store model would affect the codebase. That wasn't an issue since this alias wasn't used throughout the project and other spree/spree-contrib gems.
CI passed and this got rid of a loud warning message (printed many times on a single endpoint), but others remain that feel a bit trickier compared to "simply removing them". For example:
DEPRECATION WARNING: Spree::Price model aliases `amount` and has a method called `amount=` defined. Starting in Rails 7.2 `price=` will not be calling `amount=` anymore. You may want to additionally define `price=` to preserve the current behavior. (called from find_or_build_default_price at /Users/fdocr/.rvm/gems/ruby-3.2.2/bundler/gems/spree-b3fca9917dc8/core/app/models/concerns/spree/default_price.rb:22)
This PR in Rails has some more context on the alias_attribute deprecation warning.
Expected Behavior
No alias_attribute deprecation warnings should appear
Actual Behavior
Plenty of warnings get printed on screen
Possible Fix
I think there are two ways out:
Simply remove the alias_attribute declaration
Would likely break the gem's usage (i.e. Spree::Price#price fetch and assignment methods)
Replace the alias_attribute with an explicit method
i.e. def price=(value); amount = price; end
Steps to Reproduce
Start up spree 4.7 app
Query through UI to visualize products/variants/prices/etc
Check the app's development logs for Deprecation Warnings
Your Environment
Version used: 4.7
Any relevant stack traces ("Full trace" preferred):
18:43:19 web.1 | DEPRECATION WARNING: Spree::User model aliases `bill_address`, but `bill_address` is not an attribute. Starting in Rails 7.2, alias_attribute with non-attribute targets will raise. Use `alias_method :billing_address, :bill_address` or define the method manually. (called from try_spree_current_user at /Users/fdocr/iandi/ruby/spree/core/lib/spree/core/controller_helpers/auth.rb:67)
18:43:19 web.1 | DEPRECATION WARNING: Spree::User model aliases `ship_address`, but `ship_address` is not an attribute. Starting in Rails 7.2, alias_attribute with non-attribute targets will raise. Use `alias_method :shipping_address, :ship_address` or define the method manually. (called from try_spree_current_user at /Users/fdocr/iandi/ruby/spree/core/lib/spree/core/controller_helpers/auth.rb:67)
18:43:20 web.1 | DEPRECATION WARNING: Spree::Price model aliases `amount` and has a method called `amount=` defined. Starting in Rails 7.2 `price=` will not be calling `amount=` anymore. You may want to additionally define `price=` to preserve the current behavior. (called from find_or_build_default_price at /Users/fdocr/iandi/ruby/spree/core/app/models/concerns/spree/default_price.rb:22)
18:43:20 web.1 | DEPRECATION WARNING: Spree::Price model aliases `compare_at_amount` and has a method called `compare_at_amount=` defined. Starting in Rails 7.2 `compare_at_price=` will not be calling `compare_at_amount=` anymore. You may want to additionally define `compare_at_price=` to preserve the current behavior. (called from find_or_build_default_price at /Users/fdocr/iandi/ruby/spree/core/app/models/concerns/spree/default_price.rb:22)
The text was updated successfully, but these errors were encountered:
Hi @fdocr - that's correct, they were defined for backwards compatibility reasons. We didn't remove these aliases in 4.7, as we didn't want to introduce unnecessary breaking changes that would affect users' codebases. That said, I think the next version of Spree would be a good moment to sort this out :)
These deprecations not a problem at this moment, and such warnings can be suppressed in Rails configuration if they cause too much noise in the logs.
As for the solution - I'm leaning towards removing the aliases. I was planning to go through the aliased attributes one by one and verify if they're used in any meaningful way in both spree and spree-contrib repos. Given that the aliases are quite simple, I think anyone relying on them in their custom code should also be able to easily upgrade.
I wanted to create this issue to see if these deprecation warnings are known/expected on Spree.
Context
I first created a draft PR (here) to see how removing
alias_attribute :contact_email, :customer_support_email
onSpree::Store
model would affect the codebase. That wasn't an issue since this alias wasn't used throughout the project and other spree/spree-contrib gems.CI passed and this got rid of a loud warning message (printed many times on a single endpoint), but others remain that feel a bit trickier compared to "simply removing them". For example:
This PR in Rails has some more context on the
alias_attribute
deprecation warning.Expected Behavior
No
alias_attribute
deprecation warnings should appearActual Behavior
Plenty of warnings get printed on screen
Possible Fix
I think there are two ways out:
alias_attribute
declarationSpree::Price#price
fetch and assignment methods)alias_attribute
with an explicit methoddef price=(value); amount = price; end
Steps to Reproduce
4.7
appYour Environment
The text was updated successfully, but these errors were encountered: