Plugin and dashboard widget registry auto-reloaded
Since #18445, the plugin and related classes may be reloaded, losing registrations - probably for plugin registrations, default dashboard widgets, modified menu items, and permissions.
The change to use
require_dependency will allow Rails to track the constants and reload them when the source files are modified, discarding the class variable. The use of
require_dependency is however required to ensure eager loading doesn't load the file twice (#18445).
The source files may need to be moved to prevent double-loading and to be excluded from autoloading.
Partially reverts 70ce8fe to reinstate autoload_once_paths as the
preferred way to load registry-type objects with class variables
containing data set up during app initialisation (e.g. plugin
registrations, menu items.)
autoload_once is compatible with using require_dependency, which is
preferred to allow Rails to track which constants are loaded, so eager
loading doesn't ever try to load the same file twice (7923c95.)
This moves all registry-type objects to app/registries/ and marks this
path as being autoload_once. The contents of this directory should be
kept at an absolute minimum to ease development.