Fix: avoid infinite loop

This commit is contained in:
Laurent Destailleur 2017-12-21 13:31:39 +01:00
parent 4a5988accb
commit 62f895e2ec

View File

@ -33,7 +33,7 @@
// Build doc
if ($action == 'builddoc' && $permissioncreate)
{
if (is_numeric(GETPOST('model')))
{
$error=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Model"));
@ -48,13 +48,13 @@ if ($action == 'builddoc' && $permissioncreate)
dol_print_error('Object must have been loaded by a fetch');
exit;
}*/
// Save last template used to generate document
if (GETPOST('model'))
{
$object->setDocModel($user, GETPOST('model','alpha'));
}
// Special case to force bank account
//if (property_exists($object, 'fk_bank'))
//{
@ -76,13 +76,13 @@ if ($action == 'builddoc' && $permissioncreate)
$outputlangs = new Translate("",$conf);
$outputlangs->setDefaultLang($newlang);
}
// To be sure vars is defined
if (empty($hidedetails)) $hidedetails=0;
if (empty($hidedesc)) $hidedesc=0;
if (empty($hideref)) $hideref=0;
if (empty($moreparams)) $moreparams=null;
$result= $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
if ($result <= 0)
{
@ -91,11 +91,15 @@ if ($action == 'builddoc' && $permissioncreate)
}
else
{
if (empty($donotredirect)) // This is se when include is done by bulk action "Bill Orders"
if (empty($donotredirect)) // This is set when include is done by bulk action "Bill Orders"
{
setEventMessages($langs->trans("FileGenerated"), null);
header('Location: '.$_SERVER['REQUEST_URI'].'#builddoc');
$urltoredirect = $_SERVER['REQUEST_URI'];
$urltoredirect = preg_replace('/#builddoc$/', '', $urltoredirect);
$urltoredirect = preg_replace('/action=builddoc&?/', '', $urltoredirect); // To avoid infinite loop
header('Location: '.$urltoredirect.'#builddoc');
exit;
}
}