From 28d5901da4499002d33f9448b925e71d8eea2e8b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 15 Jan 2020 16:45:13 +0100 Subject: [PATCH] Fix error of mysqldump not thrown in some cases --- htdocs/core/class/utils.class.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/utils.class.php b/htdocs/core/class/utils.class.php index 36d471408ee..2ac64565e9c 100644 --- a/htdocs/core/class/utils.class.php +++ b/htdocs/core/class/utils.class.php @@ -233,7 +233,7 @@ class Utils $outputdir = $conf->admin->dir_output.'/backup'; $result = dol_mkdir($outputdir); - + $errormsg = ''; // MYSQL if ($type == 'mysql' || $type == 'mysqli') @@ -296,7 +296,6 @@ class Utils $paramclear .= ' -p"'.str_replace(array('"', '`'), array('\"', '\`'), $dolibarr_main_db_pass).'"'; } - $errormsg = ''; $handle = ''; // Start call method to execute dump @@ -383,6 +382,8 @@ class Utils { // Get 2048 first chars of error message. $errormsg = fgets($handle, 2048); + //$ok=0;$errormsg=''; To force error + // Close file if ($compression == 'none') fclose($handle); if ($compression == 'gz') gzclose($handle); @@ -492,7 +493,7 @@ class Utils } // 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); $i = 0; @@ -504,7 +505,7 @@ class Utils } } - return 0; + return ($errormsg ? -1 : 0); }