diff --git a/htdocs/core/class/utils.class.php b/htdocs/core/class/utils.class.php index 37ccea748f1..58c1179e1c0 100644 --- a/htdocs/core/class/utils.class.php +++ b/htdocs/core/class/utils.class.php @@ -291,18 +291,20 @@ class Utils $ok=0; dol_syslog("Run command ".$fullcommandcrypted); $handlein = popen($fullcommandclear, 'r'); - $i=0; - while (!feof($handlein)) - { - $i++; // output line number - $read = fgets($handlein); - // Exclude warning line we don't want - if ($i == 1 && preg_match('/Warning.*Using a password/i', $read)) continue; - 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) { + $i=0; + while (!feof($handlein)) + { + $i++; // output line number + $read = fgets($handlein); + // Exclude warning line we don't want + if ($i == 1 && preg_match('/Warning.*Using a password/i', $read)) continue; + 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);