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
[WIP] Rails7 #22873
base: master
Are you sure you want to change the base?
[WIP] Rails7 #22873
Conversation
a495d2d
to
59d87c0
Compare
322ef1c
to
803369e
Compare
e698c96
to
64016c0
Compare
From Pull Request: ManageIQ/manageiq#22873
@miq-bot cross-repo-tests /all #22873 ManageIQ/manageiq-ui-classic#9119 ManageIQ/manageiq-schema#715 |
From Pull Request: ManageIQ/manageiq#22873
Rails 7 autoloading during boot doesn't use autoload_paths so you must use either to_prepare hooks, after_initialize, on_load hooks for frameworks, or by avoiding autoload entirely by manually requiring files needed to be loaded during rails boot. See also: https://guides.rubyonrails.org/v7.0/autoloading_and_reloading_constants.html#autoloading-when-the-application-boots "While booting, applications can autoload from the autoload once paths, which are managed by the once autoloader. Please check the section config.autoload_once_paths above. However, you cannot autoload from the autoload paths, which are managed by the main autoloader. This applies to code in config/initializers as well as application or engines initializers. Why? Initializers only run once, when the application boots. If you reboot the server, they run again in a new process, but reloading does not reboot the server, and initializers don't run again."
See rails commit: e3b9779cb701c63012bc1af007c71dc5a888d35a Very similar to the change found in: https://github.com/ManageIQ/activerecord-virtual_attributes/pull/133/files
Fixes the following deprecation warnings: DEPRECATION WARNING: Time#to_s(:db) is deprecated. Please use Time#to_fs(:db) instead. (called from block (2 levels) in add_metric_rollups_for at /Users/joerafaniello/Code/manageiq/spec/support/chargeback_helper.rb:43) DEPRECATION WARNING: Integer#to_s(:human_size) is deprecated. Please use Integer#to_fs(:human_size) instead. (called from block in build_disk_message at /Users/joerafaniello/Code/manageiq/app/models/vm_reconfigure_task.rb:43) DEPRECATION WARNING: Integer#to_s(:human_size) is deprecated. Please use Integer#to_fs(:human_size) instead. (called from block (3 levels) in <main> at /Users/joerafaniello/Code/manageiq/spec/models/vm_reconfigure_task_spec.rb:45) DEPRECATION WARNING: Integer#to_s(:human_size) is deprecated. Please use Integer#to_fs(:human_size) instead. (called from block (3 levels) in <main> at /Users/joerafaniello/Code/manageiq/spec/models/vm_reconfigure_task_spec.rb:58) DEPRECATION WARNING: Integer#to_s(:human_size) is deprecated. Please use Integer#to_fs(:human_size) instead. (called from block (3 levels) in <main> at /Users/joerafaniello/Code/manageiq/spec/models/vm_reconfigure_task_spec.rb:59)
Fixes the warning: DEPRECATION WARNING: ActiveSupport::TimeWithZone.name has been deprecated and from Rails 7.1 will use the default Ruby implementation. You can set `config.active_support.remove_deprecated_time_with_zone_name = true` to enable the new behavior now. (called from block in ruby_object_usage at /Users/joerafaniello/Code/manageiq/app/models/miq_worker/runner.rb:435)
We were using a private class variable. There's a public interface we can use and avoid a deprecation by switching from the variable to subclasses: ActiveSupport::DescendantsTracker.direct_descendants is deprecated and will be removed in Rails 7.1. Use ActiveSupport::DescendantsTracker.subclasses instead.
We're now eager loading subclasses when loading the parent but this is far less reliant on hacks and closer to full eager loading, which is what rails has been pushing us to do for years. Let's try it out. Rails changed in 7.0 to call subclasses from reload_schema_from_cache here: rails/rails@6f30cc0 It also changed to call descendants on the callback class (self) insead of the ActiveSupport::DescendantsTracker here: rails/rails@ffae3bd We are not expecting to be called from these locations. Avoiding descendants / subclasses calls in conditionals like this are just brittle so we need to stop hooking through these methods: if !%w[reload_schema_from_cache __update_callbacks descendants subclasses].include?(caller_locations.first.base_label)
This is an attempt to reimplement ManageIQ#22853 since that was reverted in ManageIQ#23038.
Some comments on commits jrafanie/manageiq@d6a9fba~...fe1d769 config/initializers/zeitwerk.rb
|
Checked commits jrafanie/manageiq@d6a9fba~...fe1d769 with ruby 2.7.8, rubocop 1.56.3, haml-lint 0.51.0, and yamllint app/models/vm_reconfigure_task.rb
config/initializers/zeitwerk.rb
lib/extensions/descendant_loader.rb
lib/manageiq/session.rb
lib/miq_preloader.rb
spec/lib/extensions/ar_to_model_hash_spec.rb
spec/models/vm_reconfigure_task_spec.rb
|
Part of #22052