Fix missing init of hookmanager

This commit is contained in:
Laurent Destailleur 2017-06-08 11:18:41 +02:00
parent 9c4a2594b1
commit a1144e1f66
2 changed files with 10 additions and 6 deletions

View File

@ -59,8 +59,7 @@ class HookManager
/** /**
* Init array $this->hooks with instantiated action controlers. * Init array $this->hooks with instantiated action controlers.
* First, a hook is declared by a module by adding a constant MAIN_MODULE_MYMODULENAME_HOOKS * First, a hook is declared by a module by adding a constant MAIN_MODULE_MYMODULENAME_HOOKS with value 'nameofcontext1:nameofcontext2:...' into $this->const of module descriptor file.
* with value 'nameofcontext1:nameofcontext2:...' into $this->const of module descriptor file.
* This makes $conf->hooks_modules loaded with an entry ('modulename'=>array(nameofcontext1,nameofcontext2,...)) * This makes $conf->hooks_modules loaded with an entry ('modulename'=>array(nameofcontext1,nameofcontext2,...))
* When initHooks function is called, with initHooks(list_of_contexts), an array $this->hooks is defined with instance of controler * When initHooks function is called, with initHooks(list_of_contexts), an array $this->hooks is defined with instance of controler
* class found into file /mymodule/class/actions_mymodule.class.php (if module has declared the context as a managed context). * class found into file /mymodule/class/actions_mymodule.class.php (if module has declared the context as a managed context).

View File

@ -136,6 +136,7 @@ if (! GETPOST('action','aZ09') || preg_match('/upgrade/i',GETPOST('action','aZ09
// Create the global $hookmanager object // Create the global $hookmanager object
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
$hookmanager=new HookManager($db); $hookmanager=new HookManager($db);
$hookmanager->initHooks(array('upgrade'));
if (!$db->connected) if (!$db->connected)
{ {
@ -490,12 +491,16 @@ if (! GETPOST('action','aZ09') || preg_match('/upgrade/i',GETPOST('action','aZ09
} }
} }
else else
{
//if (! empty($conf->modules))
if (! empty($conf->modules_parts['hooks'])) // If there is at least one module with one hook, we show message to say nothing was done
{ {
print '<tr><td colspan="4">'; print '<tr><td colspan="4">';
print '<b>'.$langs->trans('UpgradeExternalModule').'</b>: '.$langs->trans("None"); print '<b>'.$langs->trans('UpgradeExternalModule').'</b>: '.$langs->trans("None");
print '</td></tr>'; print '</td></tr>';
} }
} }
}
print '</table>'; print '</table>';