From 847616ae82f71e9da4c04de40325f072b68bc3f3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 2 Dec 2021 14:00:47 +0100 Subject: [PATCH] Fix error management --- htdocs/admin/tools/export.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/htdocs/admin/tools/export.php b/htdocs/admin/tools/export.php index 1668e4f4c67..21f7a61bafb 100644 --- a/htdocs/admin/tools/export.php +++ b/htdocs/admin/tools/export.php @@ -189,15 +189,16 @@ if ($what == 'mysql') $ok=0; dol_syslog("Run command ".$fullcommandcrypted); $handlein = popen($fullcommandclear, 'r'); - while (!feof($handlein)) - { - $read = fgets($handlein); - fwrite($handle,$read); - if (preg_match('/'.preg_quote('-- Dump completed').'/i',$read)) $ok=1; - elseif (preg_match('/'.preg_quote('SET SQL_NOTES=@OLD_SQL_NOTES').'/i',$read)) $ok=1; + if ($handlein) { + while (!feof($handlein)) + { + $read = fgets($handlein); + fwrite($handle,$read); + if (preg_match('/'.preg_quote('-- Dump completed').'/i',$read)) $ok=1; + elseif (preg_match('/'.preg_quote('SET SQL_NOTES=@OLD_SQL_NOTES').'/i',$read)) $ok=1; + } + pclose($handlein); } - pclose($handlein); - if ($compression == 'none') fclose($handle); if ($compression == 'gz') gzclose($handle); if ($compression == 'bz') bzclose($handle);