Try a better fix for #18105
This commit is contained in:
parent
a2de6c00a0
commit
d3f324c2d4
@ -254,16 +254,29 @@ class HookManager
|
||||
// Hooks that must return int (hooks with type 'addreplace')
|
||||
if ($hooktype == 'addreplace')
|
||||
{
|
||||
$resaction += $actionclassinstance->$method($parameters, $object, $action, $this); // $object and $action can be changed by method ($object->id during creation for example or $action to go back to other action for example)
|
||||
if ($resaction < 0 || !empty($actionclassinstance->error) || (!empty($actionclassinstance->errors) && count($actionclassinstance->errors) > 0))
|
||||
{
|
||||
$resactiontmp = $actionclassinstance->$method($parameters, $object, $action, $this); // $object and $action can be changed by method ($object->id during creation for example or $action to go back to other action for example)
|
||||
$resaction += $resactiontmp;
|
||||
|
||||
if ($resactiontmp < 0 || !empty($actionclassinstance->error) || (!empty($actionclassinstance->errors) && count($actionclassinstance->errors) > 0)) {
|
||||
$error++;
|
||||
$this->error = $actionclassinstance->error; $this->errors = array_merge($this->errors, (array) $actionclassinstance->errors);
|
||||
dol_syslog("Error on hook module=".$module.", method ".$method.", class ".get_class($actionclassinstance).", hooktype=".$hooktype.(empty($this->error) ? '' : " ".$this->error).(empty($this->errors) ? '' : " ".join(",", $this->errors)), LOG_ERR);
|
||||
}
|
||||
|
||||
if (isset($actionclassinstance->results) && is_array($actionclassinstance->results)) $this->resArray = array_merge($this->resArray, $actionclassinstance->results);
|
||||
if (!empty($actionclassinstance->resprints)) $this->resPrint .= $actionclassinstance->resprints;
|
||||
if (isset($actionclassinstance->results) && is_array($actionclassinstance->results)) {
|
||||
if ($resactiontmp > 0) {
|
||||
$this->resArray = $actionclassinstance->results;
|
||||
} else {
|
||||
$this->resArray = array_merge($this->resArray, $actionclassinstance->results);
|
||||
}
|
||||
}
|
||||
if (!empty($actionclassinstance->resprints)) {
|
||||
if ($resactiontmp > 0) {
|
||||
$this->resPrint = $actionclassinstance->resprints;
|
||||
} else {
|
||||
$this->resPrint .= $actionclassinstance->resprints;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Generic hooks that return a string or array (printLeftBlock, formAddObjectLine, formBuilddocOptions, ...)
|
||||
else {
|
||||
|
||||
@ -7754,11 +7754,12 @@ function complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type,
|
||||
{
|
||||
$parameters = array('object' => $object, 'mode' => $mode, 'head' => $head);
|
||||
$reshook = $hookmanager->executeHooks('completeTabsHead', $parameters);
|
||||
if ($reshook > 0)
|
||||
{
|
||||
if ($reshook > 0) { // Hook ask to replace completely the array
|
||||
$head = $hookmanager->resArray;
|
||||
$h = count($head);
|
||||
} else { // Hook
|
||||
$head = array_merge($head, $hookmanager->resArray);
|
||||
}
|
||||
$h = count($head);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user