Open marinaglancy opened 3 months ago
maybe even one more check, that the current plugin is actually installed:
if (during_initial_install() || isset($CFG->upgraderunning) || !get_config('PLUGINNAME', 'version')) {
// Do nothing during installation or upgrade.
return;
}
Big difference between hook callbacks and legacy lib.php callbacks is that hook callbacks are executed during install and upgrade. There is a caution about it in devdocs: https://moodledev.io/docs/4.4/apis/core/hooks#registering-of-hook-callbacks
Many developers (including myself) already hit this problem when hook callbacks throw exceptions during web installation or upgrade.
It would help if MDLCode automatically generated the following code in the hook callbacks:
Developers can always remove it if they do want the hook callback to be executed during installation/upgrade