If a module provides a hook for declaring a new "component" (bundle, plugin, etc), then it needs to have a hook_modules_enabled() implementation that clears the static caches for those components, if a module providing a new component has been enabled.
Examples: search_api_modules_enabled(), rules_modules_enabled(), ctools_modules_enabled(), etc.
Even commerce_payment_modules_enabled() follows this convention.
For example, we have hook_commerce_customer_profile_type_info(). Shipping uses it to provide a "shipping" customer profile type.
But since commerce_customer_modules_enabled() doesn't clear the commerce_customer_profile_types static, calling commerce_customer_profile_types() before a page reload gives you an array with only "billing".
This breaks drush site-install in many cases, because it installs all modules in one go (no reloads).
As far as I can see, the problem exists in: customer, order, line_item, product submodules.
Comment | File | Size | Author |
---|---|---|---|
#1 | 1715436-reset-statics.patch | 2.46 KB | bojanz |
Comments
Comment #1
bojanz CreditAttribution: bojanz commentedTurns out line_item did clear its statics. Applied the same pattern to customer and product, and added a clear for order states and statuses.
Comment #2
rszrama CreditAttribution: rszrama commentedI went ahead and added a commerce_payment_methods_reset() function and used it. Our payment transaction entity type uses payment methods for bundles, so it deserved to be cleared and reset as well.