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.
Is xautoload()->registerModule(__FILE__);
actually a requirement for mymodule.module files? If I understand https://drupal.org/node/1976210 well, it is needed for e.g. uninstall to work well.
If required, is mymodule.module preferred over mymodule.install?
Comments
Comment #1
donquixote CreditAttribution: donquixote commentedAh, good question.
It is only necessary if you want class loading for this module to be available on uninstall.
Typically, during uninstall, your module is not enabled, so any classes that would be available with xautoload are not available.
This is the same with core autoloading, afaik: Your classes are not available on uninstall.
Usually this is not a problem, because you don't do any magic things in your uninstall.
Only if you want to use your classes in hook_uninstall(), then this trick helps you to make them available :)
Beware though:
Not only is your own module not enabled, also any dependency might be not enabled on uninstall time.
E.g. if mymodule depends on othermodule, and mymodule_uninstall() wants to use a class from othermodule, you will have a difficult time.
Does make sense?
Comment #2
Vacilando CreditAttribution: Vacilando commentedYes, it's clear, thank you!