Fix error of mysqldump not thrown in some cases

This commit is contained in:
Laurent Destailleur 2020-01-15 16:45:13 +01:00
parent ed0e4b53d4
commit 28d5901da4

View File

@ -233,7 +233,7 @@ class Utils
$outputdir = $conf->admin->dir_output.'/backup'; $outputdir = $conf->admin->dir_output.'/backup';
$result = dol_mkdir($outputdir); $result = dol_mkdir($outputdir);
$errormsg = '';
// MYSQL // MYSQL
if ($type == 'mysql' || $type == 'mysqli') if ($type == 'mysql' || $type == 'mysqli')
@ -296,7 +296,6 @@ class Utils
$paramclear .= ' -p"'.str_replace(array('"', '`'), array('\"', '\`'), $dolibarr_main_db_pass).'"'; $paramclear .= ' -p"'.str_replace(array('"', '`'), array('\"', '\`'), $dolibarr_main_db_pass).'"';
} }
$errormsg = '';
$handle = ''; $handle = '';
// Start call method to execute dump // Start call method to execute dump
@ -383,6 +382,8 @@ class Utils
{ {
// Get 2048 first chars of error message. // Get 2048 first chars of error message.
$errormsg = fgets($handle, 2048); $errormsg = fgets($handle, 2048);
//$ok=0;$errormsg=''; To force error
// Close file // Close file
if ($compression == 'none') fclose($handle); if ($compression == 'none') fclose($handle);
if ($compression == 'gz') gzclose($handle); if ($compression == 'gz') gzclose($handle);
@ -492,7 +493,7 @@ class Utils
} }
// Clean old files // Clean old files
if ($keeplastnfiles > 0) if (! $errormsg && $keeplastnfiles > 0)
{ {
$tmpfiles = dol_dir_list($conf->admin->dir_output.'/backup', 'files', 0, '', '(\.err|\.old|\.sav)$', 'date', SORT_DESC); $tmpfiles = dol_dir_list($conf->admin->dir_output.'/backup', 'files', 0, '', '(\.err|\.old|\.sav)$', 'date', SORT_DESC);
$i = 0; $i = 0;
@ -504,7 +505,7 @@ class Utils
} }
} }
return 0; return ($errormsg ? -1 : 0);
} }