Skip to content

Commit

Permalink
FIX avoid from re-initializing array result on nested hook getEntity (D…
Browse files Browse the repository at this point in the history
  • Loading branch information
kkhelifa-opendsi authored Sep 9, 2024
1 parent 21ec7ce commit d29ebee
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions htdocs/core/class/hookmanager.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ public function executeHooks($method, $parameters = array(), &$object = null, &$

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

Expand Down Expand Up @@ -263,9 +264,9 @@ public function executeHooks($method, $parameters = array(), &$object = null, &$

if (isset($actionclassinstance->results) && is_array($actionclassinstance->results)) {
if ($resactiontmp > 0) {
$this->resArray = $actionclassinstance->results;
$localResArray = $actionclassinstance->results;
} else {
$this->resArray = array_merge($this->resArray, $actionclassinstance->results);
$localResArray = array_merge($localResArray, $actionclassinstance->results);
}
}
if (!empty($actionclassinstance->resprints)) {
Expand All @@ -291,7 +292,7 @@ public function executeHooks($method, $parameters = array(), &$object = null, &$
$resaction += $resactiontmp;

if (!empty($actionclassinstance->results) && is_array($actionclassinstance->results)) {
$this->resArray = array_merge($this->resArray, $actionclassinstance->results);
$localResArray = array_merge($localResArray, $actionclassinstance->results);
}
if (!empty($actionclassinstance->resprints)) {
$localResPrint .= $actionclassinstance->resprints;
Expand Down Expand Up @@ -321,6 +322,7 @@ public function executeHooks($method, $parameters = array(), &$object = null, &$
}

$this->resPrint = $localResPrint;
$this->resArray = $localResArray;

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

0 comments on commit d29ebee

Please sign in to comment.