Status: Development in progress
Affects Version/s: 3.8, DEV backlog
Fix Version/s: None
Component/s: Files API
We should test as much file-related functionality as possible. Some ideas:
- Test file_trash_cleanup_task scheduled task
- Run all available unit tests
- Run all available functional tests
- Create / edit / delete a resource in a course with single / many files and single / many sub-directories.
Pull from Repository:
Pull Master Branch:MDL-65857_optimize_mdl_files_entries
Those entries do not bring any new information for top-level directory ("/") - each resource simply has one entry like that and the entry is always identical. It's content hash is: da39a3ee5e6b4b0d3255bfef95601890afd80709
Statistics from one of our databases:
- mdl_files table has about 90 million records.
- Out of those, there are about 20 million "." rows.
Since this information is redundant, the 20 million rows could possibly be removed from the database and replaced with a bit of PHP logic when handling the files.
Bear in mind that the "." entries are still needed for sub-directories. The optimization will help most in the installations with a lot of single file resources.
I have implemented the optimization and checked all the places I could think of where that could cause some side effects. All units tests have been either updated or related code fixed. But of course, since this is a core change, there may be some side effect I have missed.
The patch makes Moodle to try to avoid using ./ entry but as a fallback, fake mock-up entry for ./ is returned.
Of course this change may break plugins that use the mdl_files table directly - but from what I can see if files API is used, then the risk is low.
However - this change should be documented in the Moodle files documentation and in the dev changelog.
I would suggest that the code changes are now reviewed by another developer. If we decide to include them in Moodle core and there are no obvious risks here, then we need to handle one more thing - an upgrade during which all top level "." entries are deleted.