Bug #104718
openFilelist extremly slow having a lot of folders with subfolders on Rootlevel
0%
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)