From 5dc194bc583a58bbd0cdfa6196d694b1114f4500 Mon Sep 17 00:00:00 2001 From: Noel Dieschburg Date: Mon, 29 Nov 2021 14:46:06 +0100 Subject: [PATCH 1/3] _#320326 : fixes performance problem when downloading a folder --- main/document/downloadfolder.inc.php | 32 ++++++++++++++++------------ 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/main/document/downloadfolder.inc.php b/main/document/downloadfolder.inc.php index f064202739b..9409deba2f6 100755 --- a/main/document/downloadfolder.inc.php +++ b/main/document/downloadfolder.inc.php @@ -127,6 +127,8 @@ function fixDocumentNameCallback($p_event, &$p_header) $courseInfo['code'] ); +$filesToZip=[]; + // Admins are allowed to download invisible files if (api_is_allowed_to_edit()) { // Set the path that will be used in the query @@ -180,14 +182,15 @@ function fixDocumentNameCallback($p_event, &$p_header) } } } - $zip->add( - $sysCoursePath.$courseInfo['path'].'/document'.$not_deleted_file['path'], - PCLZIP_OPT_REMOVE_PATH, - $sysCoursePath.$courseInfo['path'].'/document'.$remove_dir, - PCLZIP_CB_PRE_ADD, - 'fixDocumentNameCallback' - ); + $filesToZip[]= $sysCoursePath.$courseInfo['path'].'/document'.$not_deleted_file['path']; } + $zip->add( + $filesToZip, + PCLZIP_OPT_REMOVE_PATH, + $sysCoursePath.$courseInfo['path'].'/document'.$remove_dir, + PCLZIP_CB_PRE_ADD, + 'fixDocumentNameCallback' + ); Session::erase('doc_files_to_download'); } else { @@ -324,14 +327,15 @@ function fixDocumentNameCallback($p_event, &$p_header) // Add all files in our final array to the zipfile for ($i = 0; $i < count($files_for_zipfile); $i++) { - $zip->add( - $sysCoursePath.$courseInfo['path'].'/document'.$files_for_zipfile[$i], - PCLZIP_OPT_REMOVE_PATH, - $sysCoursePath.$courseInfo['path'].'/document'.$remove_dir, - PCLZIP_CB_PRE_ADD, - 'fixDocumentNameCallback' - ); + $filesToZip[] = $sysCoursePath.$courseInfo['path'].'/document'.$files_for_zipfile[$i]; } + $zip->add( + $filesToZip, + PCLZIP_OPT_REMOVE_PATH, + $sysCoursePath.$courseInfo['path'].'/document'.$remove_dir, + PCLZIP_CB_PRE_ADD, + 'fixDocumentNameCallback' + ); Session::erase('doc_files_to_download'); } From 5ee73b18ae43047857c1cd8f6c1510cfcc98c6e5 Mon Sep 17 00:00:00 2001 From: Renaud Lemaire Date: Tue, 30 Nov 2021 10:24:10 +0100 Subject: [PATCH 2/3] _#320326 : fixes performance problem when downloading a folder (fix tabs) --- main/document/downloadfolder.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main/document/downloadfolder.inc.php b/main/document/downloadfolder.inc.php index 9409deba2f6..35e0517920e 100755 --- a/main/document/downloadfolder.inc.php +++ b/main/document/downloadfolder.inc.php @@ -182,7 +182,7 @@ function fixDocumentNameCallback($p_event, &$p_header) } } } - $filesToZip[]= $sysCoursePath.$courseInfo['path'].'/document'.$not_deleted_file['path']; + $filesToZip[]= $sysCoursePath.$courseInfo['path'].'/document'.$not_deleted_file['path']; } $zip->add( $filesToZip, @@ -327,7 +327,7 @@ function fixDocumentNameCallback($p_event, &$p_header) // Add all files in our final array to the zipfile for ($i = 0; $i < count($files_for_zipfile); $i++) { - $filesToZip[] = $sysCoursePath.$courseInfo['path'].'/document'.$files_for_zipfile[$i]; + $filesToZip[] = $sysCoursePath.$courseInfo['path'].'/document'.$files_for_zipfile[$i]; } $zip->add( $filesToZip, From ef7944e0ae12078c1ec428fc269cfcecacef33c6 Mon Sep 17 00:00:00 2001 From: Renaud Lemaire Date: Wed, 1 Dec 2021 11:10:03 +0100 Subject: [PATCH 3/3] #320326 : fixes performance problem when downloading a folder (PHP-CS-Fix) --- main/document/downloadfolder.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main/document/downloadfolder.inc.php b/main/document/downloadfolder.inc.php index 35e0517920e..f5e1f7b754f 100755 --- a/main/document/downloadfolder.inc.php +++ b/main/document/downloadfolder.inc.php @@ -127,7 +127,7 @@ function fixDocumentNameCallback($p_event, &$p_header) $courseInfo['code'] ); -$filesToZip=[]; +$filesToZip = []; // Admins are allowed to download invisible files if (api_is_allowed_to_edit()) { @@ -182,7 +182,7 @@ function fixDocumentNameCallback($p_event, &$p_header) } } } - $filesToZip[]= $sysCoursePath.$courseInfo['path'].'/document'.$not_deleted_file['path']; + $filesToZip[] = $sysCoursePath.$courseInfo['path'].'/document'.$not_deleted_file['path']; } $zip->add( $filesToZip,