#104718Filelist extremly slow having a lot of folders with subfolders on Rootlevel
Description
Story
Loading the file tree takes ages on a storage which has many Folders on rootlevel (122 folder ins my Case) when the folders themselves are containing a lot of subfolders.
This might even lead to max_memory exceed errors or maximum_execution time exceed
Cause
The FileStorageTreeProvides determines the presence of subfolder in a very inefficent and redundant way. Due to recursive nature of the used fuction the performance impact is extremly high.
Solution
*Step 1*
To detect if a folder has a subfolder or not it is not neccessary to fetch all subfolder one is enought so change:
https://github.com/TYPO3/typo3/blob/11.5/typo3/sysext/backend/Classes/Tree/FileStorageTreeProvider.php#L64
$hasSubfolders = !empty($folder->getSubfolders());
To:
$hasSubfolders = !empty($folder->getSubfolders(0, 1));
*Step 2*
The prepareFolderInformation already holds the information if there is a subfolder or not. So no need to determine it again.
So remove this
https://github.com/TYPO3/typo3/blob/11.5/typo3/sysext/backend/Classes/Tree/FileStorageTreeProvider.php#L207
And referre to “prepareFolderInformation[‘hasChildren’]” instead and reaad the check for InaccessibleFolder here:
https://github.com/TYPO3/typo3/blob/11.5/typo3/sysext/backend/Classes/Tree/FileStorageTreeProvider.php#L223
I applied the above changes to a my testystem and the loading time dropped from 30-55s to 2-3s.
Affected Systems:
- Confirmed on TYPO3 11
- Code looks the same in TYPO3 12 and 13 (only tested on v11)
Reviews 0
No change resolves or names this issue in its commit message, and no comment links one.
Fix this issue
Start the commit message of your patch with this. Add what the patch does, and the versions it goes to in "Releases:". How to create a patch
- Commit message
-
[BUGFIX] Filelist extremly slow having a lot of folders with subfolders on Rootlevel Resolves: #104718 Releases: main