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

donquixote’s picture

Ah, 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?

Vacilando’s picture

Status: Active » Fixed

Yes, it's clear, thank you!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.