Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move line_item_comparison_hooks config to Spree::Config #6050

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mamhoff
Copy link
Contributor

@mamhoff mamhoff commented Dec 21, 2024

Setting line item comparison hooks in a config.to_prepare block will currently autoload the Spree::Order model (and subsequently any model referenced in that class definition), slowing down the boot process in development mode (when we want our app/ directory to be autoloaded.

This moves setting those hooks to Spree::Config, which is already loaded by the time initializers run. This allows us to move code out of config.to_prepare hooks, and stop the order class from being inadvertently eager loaded.

Checklist

Check out our PR guidelines for more details.

The following are mandatory for all PRs:

The following are not always needed:

  • 📖 I have updated the README to account for my changes.
  • 📑 I have documented new code with YARD.
  • 🛣️ I have opened a PR to update the guides.
  • ✅ I have added automated tests to cover my changes.
  • 📸 I have attached screenshots to demo visual changes.

Setting line item comparison hooks in a `config.to_prepare` block will
currently autoload the Spree::Order model (and subsequently any model
referenced in that class definition), slowing down the boot process in
development mode (when we want our app/ directory to be autoloaded.

This moves setting those hooks to Spree::Config, which is already loaded
by the time initializers run. This allows us to move code out of
`config.to_prepare` hooks, and stop the order class from being
inadvertently eager loaded.
@mamhoff mamhoff requested a review from a team as a code owner December 21, 2024 16:05
@github-actions github-actions bot added changelog:solidus_core Changes to the solidus_core gem changelog:solidus_promotions Changes to the solidus_promotions gem labels Dec 21, 2024
def line_item_comparison_hooks=(value)
Spree::Config.line_item_comparison_hooks = value.to_a
end
deprecate :line_item_comparison_hooks=, deprecator: Spree.deprecator
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a deprecation message?

@mamhoff mamhoff marked this pull request as draft January 9, 2025 11:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog:solidus_core Changes to the solidus_core gem changelog:solidus_promotions Changes to the solidus_promotions gem
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants