Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
#1905544: Cache mailsystem_get_classes() between requests
That issue did a good job of fixing the caching issue but in reality calls in hook_init are very very performance heavy and so as a result we should look into alternatives,
Like generating the mail_system classes elsewhere, i.e. the first time the module is installed and never again until cache is cleared.
Comments
Comment #2
david_garcia CreditAttribution: david_garcia commentedComment #3
heddnIt is a bit abusive, but not too much so. Implement hook_flush_caches and and don't return any value. That will get called on every cache flush. With the added benefit that during module install, it will also get called.