Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into

develop
This commit is contained in:
Laurent Destailleur
2022-11-16 20:35:29 +01:00
19 changed files with 230 additions and 189 deletions

View File

@@ -203,9 +203,10 @@ class Utils
* @param string $file 'auto' or filename to build
* @param int $keeplastnfiles Keep only last n files (not used yet)
* @param int $execmethod 0=Use default method (that is 1 by default), 1=Use the PHP 'exec' - need size of dump in memory, but low memory method is used if GETPOST('lowmemorydump') is set, 2=Use the 'popen' method (low memory method)
* @param int $lowmemorydump 1=Use the low memory method. If $lowmemorydump is set, it means we want to make the compression using an external pipe instead retreiving the content of the dump in PHP memory array $output_arr and then print it into the PHP pipe open with xopen().
* @return int 0 if OK, < 0 if KO (this function is used also by cron so only 0 is OK)
*/
public function dumpDatabase($compression = 'none', $type = 'auto', $usedefault = 1, $file = 'auto', $keeplastnfiles = 0, $execmethod = 0)
public function dumpDatabase($compression = 'none', $type = 'auto', $usedefault = 1, $file = 'auto', $keeplastnfiles = 0, $execmethod = 0, $lowmemorydump = 0)
{
global $db, $conf, $langs, $dolibarr_main_data_root;
global $dolibarr_main_db_name, $dolibarr_main_db_host, $dolibarr_main_db_user, $dolibarr_main_db_port, $dolibarr_main_db_pass;
@@ -358,10 +359,6 @@ class Utils
$handle = '';
// If $lowmemorydump is set, it means we want to make the compression using an external pipe instead retreiving the
// content of the dump in PHP memory array $output_arr and then print it into the PHP pipe open with xopen().
$lowmemorydump = GETPOSTISSET("lowmemorydump") ? GETPOST("lowmemorydump") : getDolGlobalString('MAIN_LOW_MEMORY_DUMP');
// Start call method to execute dump
$fullcommandcrypted = $command." ".$paramcrypted." 2>&1";
$fullcommandclear = $command." ".$paramclear." 2>&1";
@@ -377,23 +374,23 @@ class Utils
}
} else {
if ($compression == 'none') {
$fullcommandclear .= ' > "'.dol_sanitizePathName($outputfile).'"';
$fullcommandcrypted .= ' > "'.dol_sanitizePathName($outputfile).'"';
$fullcommandclear .= ' | grep -v "Warning: Using a password on the command line interface can be insecure." > "'.dol_sanitizePathName($outputfile).'"';
$fullcommandcrypted .= ' | grep -v "Warning: Using a password on the command line interface can be insecure." > "'.dol_sanitizePathName($outputfile).'"';
$handle = 1;
} elseif ($compression == 'gz') {
$fullcommandclear .= ' | gzip > "'.dol_sanitizePathName($outputfile).'"';
$fullcommandcrypted .= ' | gzip > "'.dol_sanitizePathName($outputfile).'"';
$paramcrypted .= ' | gzip';
$fullcommandclear .= ' | grep -v "Warning: Using a password on the command line interface can be insecure." | gzip > "'.dol_sanitizePathName($outputfile).'"';
$fullcommandcrypted .= ' | grep -v "Warning: Using a password on the command line interface can be insecure." | gzip > "'.dol_sanitizePathName($outputfile).'"';
$paramcrypted .= ' | grep -v "Warning: Using a password on the command line interface can be insecure." | gzip';
$handle = 1;
} elseif ($compression == 'bz') {
$fullcommandclear .= ' | bzip2 > "'.dol_sanitizePathName($outputfile).'"';
$fullcommandcrypted .= ' | bzip2 > "'.dol_sanitizePathName($outputfile).'"';
$paramcrypted .= ' | bzip2';
$fullcommandclear .= ' | grep -v "Warning: Using a password on the command line interface can be insecure." | bzip2 > "'.dol_sanitizePathName($outputfile).'"';
$fullcommandcrypted .= ' | grep -v "Warning: Using a password on the command line interface can be insecure." | bzip2 > "'.dol_sanitizePathName($outputfile).'"';
$paramcrypted .= ' | grep -v "Warning: Using a password on the command line interface can be insecure." | bzip2';
$handle = 1;
} elseif ($compression == 'zstd') {
$fullcommandclear .= ' | zstd > "'.dol_sanitizePathName($outputfile).'"';
$fullcommandcrypted .= ' | zstd > "'.dol_sanitizePathName($outputfile).'"';
$paramcrypted .= ' | zstd';
$fullcommandclear .= ' | grep -v "Warning: Using a password on the command line interface can be insecure." | zstd > "'.dol_sanitizePathName($outputfile).'"';
$fullcommandcrypted .= ' | grep -v "Warning: Using a password on the command line interface can be insecure." | zstd > "'.dol_sanitizePathName($outputfile).'"';
$paramcrypted .= ' | grep -v "Warning: Using a password on the command line interface can be insecure." | zstd';
$handle = 1;
}
}