Commit a8bc4197 authored by rjsmelo's avatar rjsmelo

[bp/r66012][FIX] Fix timeout when browsing file galleries with thousands of...

[bp/r66012][FIX] Fix timeout when browsing file galleries with thousands of files (Partial Backport) 
parent 7433f56a
......@@ -1853,12 +1853,14 @@ class FileGalLib extends TikiLib
*/
function _getGalleryChildrenIdsList($allIds, &$subtree, $parentId)
{
foreach ($allIds as $k => $v) {
if ($v['parentId'] == $parentId) {
$galleryId = $v['galleryId'];
$subtree[] = (int)$galleryId;
$this->_getGalleryChildrenIdsList($allIds, $subtree, $galleryId);
}
if (empty($allIds[$parentId])) {
return;
}
foreach($allIds[$parentId] as $child) {
$galleryId = $child;
$subtree[] = (int)$galleryId;
$this->_getGalleryChildrenIdsList($allIds, $subtree, $galleryId);
}
}
......@@ -1873,12 +1875,14 @@ class FileGalLib extends TikiLib
*/
function _getGalleryChildrenIdsTree($allIds, &$subtree, $parentId)
{
foreach ($allIds as $v) {
if ($v['parentId'] == $parentId) {
$galleryId = $v['galleryId'];
$subtree[ (int)$galleryId ] = [];
$this->_getGalleryChildrenIdsTree($allIds, $subtree[$galleryId], $galleryId);
}
if (empty($allIds[$parentId])) {
return;
}
foreach($allIds[$parentId] as $child) {
$galleryId = $child;
$subtree[ (int)$galleryId ] = [];
$this->_getGalleryChildrenIdsTree($allIds, $subtree[$galleryId], $galleryId);
}
}
// Get a tree or a list of a gallery children ids, optionnally under a specific parentId
......@@ -1887,13 +1891,18 @@ class FileGalLib extends TikiLib
{
$allIds = $this->getGalleriesParentIds();
$allChildIds = [];
foreach ($allIds as $v) {
$allChildIds[$v['parentId']][] = $v['galleryId'];
}
switch ($format) {
case 'list':
$this->_getGalleryChildrenIdsList($allIds, $subtree, $parentId);
$this->_getGalleryChildrenIdsList($allChildIds, $subtree, $parentId);
break;
case 'tree':
default:
$this->_getGalleryChildrenIdsTree($allIds, $subtree, $parentId);
$this->_getGalleryChildrenIdsTree($allChildIds, $subtree, $parentId);
}
}
......
......@@ -96,9 +96,15 @@ if (empty($galleryId) && isset($_REQUEST['parentId'])) {
$smarty->display('error.tpl');
die;
}
$gal_info['usedSize'] = $filegallib->getUsedSize($galleryId);
$gal_info['maxQuota'] = $filegallib->getQuota($gal_info['parentId']);
$gal_info['minQuota'] = $filegallib->getMaxQuotaDescendants($galleryId);
if ($prefs['fgal_quota_per_fgal'] === 'y') {
$gal_info['usedSize'] = $filegallib->getUsedSize($galleryId);
$gal_info['maxQuota'] = $filegallib->getQuota($gal_info['parentId']);
$gal_info['minQuota'] = $filegallib->getMaxQuotaDescendants($galleryId);
} else {
$gal_info['usedSize'] = 0;
$gal_info['maxQuota'] = 0;
$gal_info['minQuota'] = 0;
}
if ($galleryId == $prefs['fgal_root_user_id'] && $tiki_p_admin_file_galleries !== 'y') {
include_once('tiki-sefurl.php');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment