diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index 089e9fb6717..c1d11c9290b 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -144,7 +144,7 @@ class HookManager */ public function executeHooks($method, $parameters = array(), &$object = '', &$action = '') { - if (!is_array($this->hooks) || empty($this->hooks)) return ''; + if (!is_array($this->hooks) || empty($this->hooks)) return 0; // No hook available, do nothing. $parameters['context'] = join(':', $this->contextarray); //dol_syslog(get_class($this).'::executeHooks method='.$method." action=".$action." context=".$parameters['context']); @@ -225,14 +225,14 @@ class HookManager // Loop on each hook to qualify modules that have declared context $modulealreadyexecuted = array(); - $resaction = 0; $error = 0; $result = ''; + $resaction = 0; $error = 0; foreach ($this->hooks as $context => $modules) // $this->hooks is an array with context as key and value is an array of modules that handle this context { if (!empty($modules)) { foreach ($modules as $module => $actionclassinstance) { - //print "Before hook ".get_class($actionclassinstance)." method=".$method." hooktype=".$hooktype." results=".count($actionclassinstance->results)." resprints=".count($actionclassinstance->resprints)." resaction=".$resaction." result=".$result."
\n"; + //print "Before hook ".get_class($actionclassinstance)." method=".$method." hooktype=".$hooktype." results=".count($actionclassinstance->results)." resprints=".count($actionclassinstance->resprints)." resaction=".$resaction."
\n"; // test to avoid running twice a hook, when a module implements several active contexts if (in_array($module, $modulealreadyexecuted)) continue; @@ -290,7 +290,7 @@ class HookManager } } - //print "After hook ".get_class($actionclassinstance)." method=".$method." hooktype=".$hooktype." results=".count($actionclassinstance->results)." resprints=".count($actionclassinstance->resprints)." resaction=".$resaction." result=".$result."
\n"; + //print "After hook ".get_class($actionclassinstance)." method=".$method." hooktype=".$hooktype." results=".count($actionclassinstance->results)." resprints=".count($actionclassinstance->resprints)." resaction=".$resaction."
\n"; unset($actionclassinstance->results); unset($actionclassinstance->resprints); @@ -298,6 +298,6 @@ class HookManager } } - return ($error ?-1 : $resaction); + return ($error ? -1 : $resaction); } } diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 708bb9d7987..ba96efbfd62 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1155,6 +1155,7 @@ function dol_delete_file($file, $disableglob = 0, $nophperrors = 0, $nohook = 0, return false; } + $reshook = 0; if (empty($nohook)) { $hookmanager->initHooks(array('fileslib')); @@ -1174,17 +1175,13 @@ function dol_delete_file($file, $disableglob = 0, $nophperrors = 0, $nohook = 0, if ($reshook < 0) return false; return true; } else { - //print "x".$file." ".$disableglob;exit; - dol_syslog("reshook=".$reshook); $file_osencoded = dol_osencode($file); // New filename encoded in OS filesystem encoding charset if (empty($disableglob) && !empty($file_osencoded)) { $ok = true; $globencoded = str_replace('[', '\[', $file_osencoded); $globencoded = str_replace(']', '\]', $globencoded); - dol_syslog("globencoded=".$globencoded); $listofdir = glob($globencoded); - dol_syslog("listofdir=".join(', ', $listofdir)); if (!empty($listofdir) && is_array($listofdir)) { foreach ($listofdir as $filename)