From bd61a410589c5a85e98567fbd7cf7f34a0bc1f64 Mon Sep 17 00:00:00 2001 From: Kamel Khelifa Date: Tue, 13 Aug 2024 15:53:32 +0200 Subject: [PATCH] FIX avoid from re-initializing array result on nested hook getEntity --- htdocs/core/class/hookmanager.class.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index cb89f123a9f57..1cb35d40b8548 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -208,6 +208,7 @@ public function executeHooks($method, $parameters = array(), &$object = null, &$ // Init return properties $localResPrint = ''; + $localResArray = array(); $this->resArray = array(); $this->resNbOfHooks = 0; @@ -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)) { @@ -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; @@ -321,6 +322,7 @@ public function executeHooks($method, $parameters = array(), &$object = null, &$ } $this->resPrint = $localResPrint; + $this->resArray = $localResArray; return ($error ? -1 : $resaction); }