running hooks can be prevented by setting env var SEEDDMS_NO_EXTENSION_HOOKS

This commit is contained in:
Uwe Steinmann 2025-11-17 15:36:13 +01:00
parent 4e236cf896
commit b647e6e000

View File

@ -62,12 +62,26 @@ $application->add(new RepositoryextensionCommand($settings, $logger, $translator
$application->add(new UpdateextensionCommand($settings, $logger, $translator, $extmgr));
$application->add(new DownloadextensionCommand($settings, $logger, $translator, $extmgr));
if(isset($GLOBALS['SEEDDMS_HOOKS']['console'])) {
foreach($GLOBALS['SEEDDMS_HOOKS']['console'] as $hookObj) {
if (method_exists($hookObj, 'addCommand')) {
$hookObj->addCommand($application, ['settings'=>$settings, 'logger'=>$logger, 'translator'=>$translator, 'extmgr'=>$extmgr]);
/* If extension are not compatible with the current version of
* SeedDMS anymore, calling the hooks may fail and exit this
* script. Hence there no change to even disable an extension with
* `utils/console ext:configure --name <extname> --disable`
* In such a case the last resort is to set the environment variable
* SEEDDMS_NO_EXTENSION_HOOKS to any value, which will prevent calling
* any hooks.
*/
if (false === getenv('SEEDDMS_NO_EXTENSION_HOOKS')) {
if (isset($GLOBALS['SEEDDMS_HOOKS']['console'])) {
foreach ($GLOBALS['SEEDDMS_HOOKS']['console'] as $hookObj) {
if (method_exists($hookObj, 'addCommand')) {
$hookObj->addCommand($application, ['settings'=>$settings, 'logger'=>$logger, 'translator'=>$translator, 'extmgr'=>$extmgr]);
}
}
}
} else {
echo "NOT RUNNING HOOKS\n\n";
}
$application->run();
// vim: ts=4 sw=4 expandtab