Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX avoid from re-initializing result on nested hook getEntity #27799

Merged
merged 2 commits into from
Feb 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions htdocs/core/class/hookmanager.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public function executeHooks($method, $parameters = array(), &$object = '', &$ac
}

// Init return properties
$this->resPrint = '';
$localResPrint = '';
$this->resArray = array();
$this->resNbOfHooks = 0;

Expand Down Expand Up @@ -270,9 +270,9 @@ public function executeHooks($method, $parameters = array(), &$object = '', &$ac
}
if (!empty($actionclassinstance->resprints)) {
if ($resactiontmp > 0) {
$this->resPrint = $actionclassinstance->resprints;
$localResPrint = $actionclassinstance->resprints;
} else {
$this->resPrint .= $actionclassinstance->resprints;
$localResPrint .= $actionclassinstance->resprints;
}
}
} else {
Expand All @@ -294,7 +294,7 @@ public function executeHooks($method, $parameters = array(), &$object = '', &$ac
$this->resArray = array_merge($this->resArray, $actionclassinstance->results);
}
if (!empty($actionclassinstance->resprints)) {
$this->resPrint .= $actionclassinstance->resprints;
$localResPrint .= $actionclassinstance->resprints;
}
if (is_numeric($resactiontmp) && $resactiontmp < 0) {
$error++;
Expand All @@ -307,7 +307,7 @@ public function executeHooks($method, $parameters = array(), &$object = '', &$ac
if (!is_array($resactiontmp) && !is_numeric($resactiontmp)) {
dol_syslog('Error: Bug into hook '.$method.' of module class '.get_class($actionclassinstance).'. Method must not return a string but an int (0=OK, 1=Replace, -1=KO) and set string into ->resprints', LOG_ERR);
if (empty($actionclassinstance->resprints)) {
$this->resPrint .= $resactiontmp;
$localResPrint .= $resactiontmp;
}
}
}
Expand All @@ -320,6 +320,8 @@ public function executeHooks($method, $parameters = array(), &$object = '', &$ac
}
}

$this->resPrint = $localResPrint;

return ($error ? -1 : $resaction);
}
}
Loading