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.
Autoload has a known issue where classes are not found when a module is first enabled. A work around is to clear the cache to rebuild the cache.
I have marked the issue as major as it:
- Breaks simple tests.
- Causes errors like
Fatal error: Class 'Messaging_Method_Mail' not found
to appear when a module is first enabled.
The issue is known in the autoload issue queue #826050: Reload cache on missing class.
The issue above recommends project implement their own fix in the form of autoload_flush_caches()
from their hook_enable()
This fix may help the following threads:
Comment | File | Size | Author |
---|---|---|---|
#1 | messaging-autoload-on-enable-1351748-1.patch | 1.71 KB | JoeMcGuire |
Comments
Comment #1
JoeMcGuire CreditAttribution: JoeMcGuire commentedAttached patch adds
hook_enable()
withautoload_flush_caches()
too messaging and messaging_mail which are the two affected modules which includehook_autoload_info
This allows you to run the test Messaging_Methods_Tests and stops sites generating class not found when the module is first enabled.
Comment #2
JoeMcGuire CreditAttribution: JoeMcGuire commentedIf you are using messaging in combination with notifications it is also suffering from the same issue and has a related issue/patch: #1351782: Autoload classes not found on enable.
Comment #3
JoeMcGuire CreditAttribution: JoeMcGuire commentedIf you are enabling the modules via
hook_update_N
and drush you might still see class not found errors - this is a related issue and requires a fix in addition to this patch see #1354616: Class not found when enabling modules with hook_update and Drush.