Merge pull request #24092 from jyhere/jyhere-patch-4

Unreachable else statement removed, move some conditions...
This commit is contained in:
Laurent Destailleur 2023-03-18 11:02:43 +01:00 committed by GitHub
commit 9582a30782
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5496,7 +5496,10 @@ abstract class CommonObject
$parameters = array('modelspath'=>$modelspath, 'modele'=>$modele, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'hidedesc'=>$hidedesc, 'hideref'=>$hideref, 'moreparams'=>$moreparams); $parameters = array('modelspath'=>$modelspath, 'modele'=>$modele, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'hidedesc'=>$hidedesc, 'hideref'=>$hideref, 'moreparams'=>$moreparams);
$reshook = $hookmanager->executeHooks('commonGenerateDocument', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('commonGenerateDocument', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if (empty($reshook)) { if (!empty($reshook)) {
return $reshook;
}
dol_syslog("commonGenerateDocument modele=".$modele." outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang : 'null')); dol_syslog("commonGenerateDocument modele=".$modele." outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang : 'null'));
if (empty($modele)) { if (empty($modele)) {
@ -5548,8 +5551,14 @@ abstract class CommonObject
} }
} }
if (!$filefound) {
$this->error = $langs->trans("Error").' Failed to load doc generator with modelpaths='.$modelspath.' - modele='.$modele;
$this->errors[] = $this->error;
dol_syslog($this->error, LOG_ERR);
return -1;
}
// If generator was found // If generator was found
if ($filefound) {
global $db; // Required to solve a conception default making an include of code using $db instead of $this->db just after. global $db; // Required to solve a conception default making an include of code using $db instead of $this->db just after.
require_once $file; require_once $file;
@ -5647,21 +5656,6 @@ abstract class CommonObject
dol_syslog("Error generating document for ".__CLASS__.". Error: ".$obj->error, LOG_ERR); dol_syslog("Error generating document for ".__CLASS__.". Error: ".$obj->error, LOG_ERR);
return -1; return -1;
} }
} else {
if (!$filefound) {
$this->error = $langs->trans("Error").' Failed to load doc generator with modelpaths='.$modelspath.' - modele='.$modele;
$this->errors[] = $this->error;
dol_syslog($this->error, LOG_ERR);
} else {
$this->error = $langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists", $filefound);
$this->errors[] = $this->error;
dol_syslog($this->error, LOG_ERR);
}
return -1;
}
} else {
return $reshook;
}
} }
/** /**