From ebfe632efe645b97f67ca1bdc20c4b182be3f907 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 3 Jun 2023 15:33:46 +0200 Subject: [PATCH] Debug v18 --- htdocs/adherents/note.php | 3 ++- htdocs/asset/depreciation.php | 3 ++- htdocs/asset/depreciation_options.php | 3 ++- htdocs/asset/disposal.php | 3 ++- htdocs/asset/model/note.php | 3 ++- htdocs/asset/note.php | 3 ++- htdocs/bom/bom_note.php | 3 ++- htdocs/comm/propal/note.php | 3 ++- htdocs/commande/note.php | 3 ++- htdocs/contact/note.php | 4 +++- htdocs/core/boxes/box_dolibarr_state_board.php | 5 +++-- htdocs/core/class/hookmanager.class.php | 4 ++++ htdocs/index.php | 5 ++++- htdocs/main.inc.php | 6 ++++-- htdocs/partnership/partnership_note.php | 3 ++- htdocs/product/card.php | 6 ++---- htdocs/product/note.php | 4 +++- htdocs/product/stock/productlot_note.php | 4 ++-- htdocs/projet/note.php | 3 ++- htdocs/projet/tasks/note.php | 3 ++- htdocs/reception/note.php | 3 ++- htdocs/resource/note.php | 3 ++- htdocs/societe/card.php | 6 ++---- htdocs/societe/class/api_thirdparties.class.php | 6 ++---- htdocs/societe/note.php | 4 +++- htdocs/supplier_proposal/note.php | 3 ++- htdocs/workstation/workstation_note.php | 4 ++-- 27 files changed, 64 insertions(+), 39 deletions(-) diff --git a/htdocs/adherents/note.php b/htdocs/adherents/note.php index 4d3bc4dd638..f4f72fc93fa 100644 --- a/htdocs/adherents/note.php +++ b/htdocs/adherents/note.php @@ -85,7 +85,8 @@ $result = restrictedArea($user, 'adherent', $object->id, '', '', 'socid', 'rowid /* * Actions */ -$reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } diff --git a/htdocs/asset/depreciation.php b/htdocs/asset/depreciation.php index eae2ff45e2b..a2d283ef94b 100644 --- a/htdocs/asset/depreciation.php +++ b/htdocs/asset/depreciation.php @@ -75,7 +75,8 @@ if ($result < 0) { * Actions */ -$reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } diff --git a/htdocs/asset/depreciation_options.php b/htdocs/asset/depreciation_options.php index 5d232670105..8a5aa58d1b7 100644 --- a/htdocs/asset/depreciation_options.php +++ b/htdocs/asset/depreciation_options.php @@ -73,7 +73,8 @@ if ($result < 0) { * Actions */ -$reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } diff --git a/htdocs/asset/disposal.php b/htdocs/asset/disposal.php index 46c5be78a79..e711516132b 100644 --- a/htdocs/asset/disposal.php +++ b/htdocs/asset/disposal.php @@ -66,7 +66,8 @@ if (!isset($object->disposal_date) || $object->disposal_date === "") accessforbi * Actions */ -$reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } diff --git a/htdocs/asset/model/note.php b/htdocs/asset/model/note.php index 52d7e13e777..c3490445429 100644 --- a/htdocs/asset/model/note.php +++ b/htdocs/asset/model/note.php @@ -68,7 +68,8 @@ if (!$permissiontoread) accessforbidden(); * Actions */ -$reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } diff --git a/htdocs/asset/note.php b/htdocs/asset/note.php index dd31b723cea..10f1d81f1ae 100644 --- a/htdocs/asset/note.php +++ b/htdocs/asset/note.php @@ -65,7 +65,8 @@ if (!isModEnabled('asset')) accessforbidden(); * Actions */ -$reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } diff --git a/htdocs/bom/bom_note.php b/htdocs/bom/bom_note.php index 188c34c8c05..aba22ade7ca 100644 --- a/htdocs/bom/bom_note.php +++ b/htdocs/bom/bom_note.php @@ -74,7 +74,8 @@ restrictedArea($user, 'bom', $object->id, $object->table_element, '', '', 'rowid * Actions */ -$reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } diff --git a/htdocs/comm/propal/note.php b/htdocs/comm/propal/note.php index ace4556fb62..36eb458f252 100644 --- a/htdocs/comm/propal/note.php +++ b/htdocs/comm/propal/note.php @@ -68,7 +68,8 @@ $usercancreate = $user->hasRight("propal", "creer"); $permissionnote = $user->rights->propal->creer; // Used by the include of actions_setnotes.inc.php -$reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } diff --git a/htdocs/commande/note.php b/htdocs/commande/note.php index 57eb073bba3..edcd2a14f16 100644 --- a/htdocs/commande/note.php +++ b/htdocs/commande/note.php @@ -68,7 +68,8 @@ if (!$object->fetch($id, $ref) > 0) { * Actions */ -$reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } diff --git a/htdocs/contact/note.php b/htdocs/contact/note.php index e9e5d64f495..394dfbe7070 100644 --- a/htdocs/contact/note.php +++ b/htdocs/contact/note.php @@ -61,7 +61,9 @@ $hookmanager->initHooks(array('contactnote')); /* * Actions */ -$reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks + +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } diff --git a/htdocs/core/boxes/box_dolibarr_state_board.php b/htdocs/core/boxes/box_dolibarr_state_board.php index 17544d90299..f2d02bbedfa 100644 --- a/htdocs/core/boxes/box_dolibarr_state_board.php +++ b/htdocs/core/boxes/box_dolibarr_state_board.php @@ -78,9 +78,10 @@ class box_dolibarr_state_board extends ModeleBoxes if (empty($user->socid) && empty($conf->global->MAIN_DISABLE_GLOBAL_BOXSTATS)) { $hookmanager = new HookManager($this->db); $hookmanager->initHooks(array('index')); - $object = new stdClass; + $object = new stdClass(); $action = ''; - $hookmanager->executeHooks('addStatisticLine', array(), $object, $action); + $parameters =array(); + $hookmanager->executeHooks('addStatisticLine', $parameters, $object, $action); $boxstatItems = array(); $boxstatFromHook = ''; $boxstatFromHook = $hookmanager->resPrint; diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index e25f970fad2..2c0610084aa 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -158,6 +158,10 @@ class HookManager if (!is_array($this->hooks) || empty($this->hooks)) { return 0; // No hook available, do nothing. } + if (!is_array($parameters)) { + dol_syslog('executeHooks was called with a non array $parameters. Surely a bug.', LOG_WARNING); + $parameters = array(); + } $parameters['context'] = join(':', $this->contextarray); //dol_syslog(get_class($this).'::executeHooks method='.$method." action=".$action." context=".$parameters['context']); diff --git a/htdocs/index.php b/htdocs/index.php index 361de385a20..3a015f61bde 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -130,7 +130,10 @@ if (empty($conf->global->MAIN_REMOVE_INSTALL_WARNING)) { //if (!empty($message)) $message.='
'; $message .= info_admin($langs->transnoentities("WarningConfFileMustBeReadOnly").' '.$langs->trans("WarningUntilDirRemoved", DOL_DOCUMENT_ROOT."/install"), 0, 0, '1', 'clearboth'); } - $reshook = $hookmanager->executeHooks('infoadmin', $action); // Note that $action and $object may have been modified by some hooks + + $object = new stdClass(); + $parameters = array(); + $reshook = $hookmanager->executeHooks('infoadmin', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook == 0) { $message .= $hookmanager->resPrint; } diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 760412955f1..dd13cc79774 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1079,7 +1079,8 @@ if (!defined('NOLOGIN')) { } $action = ''; - $reshook = $hookmanager->executeHooks('updateSession', array(), $user, $action); + $parameters = array(); + $reshook = $hookmanager->executeHooks('updateSession', $parameters, $user, $action); if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } @@ -3708,7 +3709,8 @@ if (!function_exists("llxFooter")) { } } - $reshook = $hookmanager->executeHooks('beforeBodyClose'); // Note that $action and $object may have been modified by some hooks + $parameters = array(); + $reshook = $hookmanager->executeHooks('beforeBodyClose', $parameters); // Note that $action and $object may have been modified by some hooks if ($reshook > 0) { print $hookmanager->resPrint; } diff --git a/htdocs/partnership/partnership_note.php b/htdocs/partnership/partnership_note.php index b0e16f7f3a5..3fc15e362ac 100644 --- a/htdocs/partnership/partnership_note.php +++ b/htdocs/partnership/partnership_note.php @@ -76,7 +76,8 @@ if ($object->id > 0 && !($object->fk_soc > 0) && $managedfor == 'thirdparty') ac * Actions */ -$reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 99071758252..672d7575e3f 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -358,12 +358,10 @@ if (empty($reshook)) { // External modules should update their ones too if (!$error) { + $parameters = array('soc_origin' => $productOrigin->id, 'soc_dest' => $object->id); $reshook = $hookmanager->executeHooks( 'replaceProduct', - array( - 'soc_origin' => $productOrigin->id, - 'soc_dest' => $object->id, - ), + $parameters, $object, $action ); diff --git a/htdocs/product/note.php b/htdocs/product/note.php index a3f02813ee0..54c214224d5 100644 --- a/htdocs/product/note.php +++ b/htdocs/product/note.php @@ -70,7 +70,9 @@ $hookmanager->initHooks(array('productnote')); /* * Actions */ -$reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks + +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } diff --git a/htdocs/product/stock/productlot_note.php b/htdocs/product/stock/productlot_note.php index c8cd43f2091..e0e274f05bd 100644 --- a/htdocs/product/stock/productlot_note.php +++ b/htdocs/product/stock/productlot_note.php @@ -64,8 +64,8 @@ $permissionnote = $user->rights->produit->lire; // Used by the include of action /* * Actions */ - -$reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } diff --git a/htdocs/projet/note.php b/htdocs/projet/note.php index dd4672fa98b..20392059916 100644 --- a/htdocs/projet/note.php +++ b/htdocs/projet/note.php @@ -57,7 +57,8 @@ $permissionnote = $user->hasRight('projet', 'creer'); // Used by the include of * Actions */ -$reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } diff --git a/htdocs/projet/tasks/note.php b/htdocs/projet/tasks/note.php index 01c39c990f4..71f4a25e875 100644 --- a/htdocs/projet/tasks/note.php +++ b/htdocs/projet/tasks/note.php @@ -98,7 +98,8 @@ $permissionnote = ($user->rights->projet->creer || $user->rights->projet->all->c * Actions */ -$reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } diff --git a/htdocs/reception/note.php b/htdocs/reception/note.php index 1d8688a35e6..3f83d8d2b2f 100644 --- a/htdocs/reception/note.php +++ b/htdocs/reception/note.php @@ -103,7 +103,8 @@ if ($origin == 'reception') { * Actions */ -$reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } diff --git a/htdocs/resource/note.php b/htdocs/resource/note.php index d2c02df0481..3bf258ea9dc 100644 --- a/htdocs/resource/note.php +++ b/htdocs/resource/note.php @@ -58,7 +58,8 @@ $permissionnote = $user->rights->resource->write; // Used by the include of acti * Actions */ -$reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 3f62deb8a98..75e53fc72c2 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -320,10 +320,8 @@ if (empty($reshook)) { // External modules should update their ones too if (!$error) { - $reshook = $hookmanager->executeHooks('replaceThirdparty', array( - 'soc_origin' => $soc_origin->id, - 'soc_dest' => $object->id - ), $object, $action); + $parameters = array('soc_origin' => $soc_origin->id, 'soc_dest' => $object->id); + $reshook = $hookmanager->executeHooks('replaceThirdparty', $parameters, $object, $action); if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index ef7f3d00e89..73eae447dcc 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -475,10 +475,8 @@ class Thirdparties extends DolibarrApi // External modules should update their ones too if (!$error) { - $reshook = $hookmanager->executeHooks('replaceThirdparty', array( - 'soc_origin' => $soc_origin->id, - 'soc_dest' => $object->id - ), $soc_dest, $action); + $parameters = array('soc_origin' => $soc_origin->id, 'soc_dest' => $object->id); + $reshook = $hookmanager->executeHooks('replaceThirdparty', $parameters, $soc_dest, $action); if ($reshook < 0) { //setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); diff --git a/htdocs/societe/note.php b/htdocs/societe/note.php index 32ec4bbe567..f37f804f6a9 100644 --- a/htdocs/societe/note.php +++ b/htdocs/societe/note.php @@ -65,7 +65,9 @@ $result = restrictedArea($user, 'societe', $object->id, '&societe'); /* * Actions */ -$reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks + +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } diff --git a/htdocs/supplier_proposal/note.php b/htdocs/supplier_proposal/note.php index 2f514b95d31..bc65f6450fb 100644 --- a/htdocs/supplier_proposal/note.php +++ b/htdocs/supplier_proposal/note.php @@ -63,7 +63,8 @@ $usercancreate = $user->hasRight("supplier_propal", "write"); $permissionnote = $user->rights->supplier_proposal->creer; // Used by the include of actions_setnotes.inc.php -$reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } diff --git a/htdocs/workstation/workstation_note.php b/htdocs/workstation/workstation_note.php index e3e98e17d85..52bbd2498af 100644 --- a/htdocs/workstation/workstation_note.php +++ b/htdocs/workstation/workstation_note.php @@ -65,8 +65,8 @@ restrictedArea($user, $object->element, $object->id, $object->table_element, 'wo /* * Actions */ - -$reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); }