- 🇬🇧United Kingdom very_random_man
I've just run into this issue too on Drupal 9.5.9. I created a custom entity module with drush generate and later added hook_theme and template_preprocess.
If I use drush cr, everything works as expected. If I use 'Flush all caches' in the admin menu, the module's theme entry is missing from the theme registry. My temporary (and very hacky) workaround is to detect if it's missing from the registry in hook_theme_registry_alter and then put it back. Not ideal but needs must. ;-)
- 🇬🇧United Kingdom aaron.ferris
Weird, both admin_toolbar_tools
flushAll()
anddrush cr
calldrupal_flush_all_caches()
If anything it's
drush cr
that has more going on.... - 🇬🇧United Kingdom very_random_man
I noticed one of the guys above had a workaround to rename and reinstall the module. In my case i didn't create the module-name.module file until after I'd been using my module for a while. I wonder if that is connected? I seem to remember it wouldn't register the module file until I did a drush cr rather than an admin toolbar Flush All Caches. Maybe there's a clue in that?
- 🇦🇷Argentina andreses
Solution:
In fact, the problem is when the module is installed without the "module" file and it is added later. This causes the "module" file to not be registered. So when clearing the cache from the interface the "module" file is not consulted. The solution, change the "info.yml" of the module. This will cause good old Drupal to detect the change and rebuild the record and thus read the "module" file.
What type of change?, for example the version, if you have:
version: '1.0.0'
give it for example:
version: '1.0.1'
tested on Drupal 9.5 and 10 - 🇨🇴Colombia diegoluisr
I needed to reintall the module, it is not possible in all cases, but is a solution.