-
Bug
-
Resolution: Unresolved
-
Trivial
-
None
-
2.7.17, 2.9.9, 3.0.7, 3.1.3, 3.5.1, 3.7.1, 3.8
-
MOODLE_27_STABLE, MOODLE_29_STABLE, MOODLE_30_STABLE, MOODLE_31_STABLE, MOODLE_35_STABLE, MOODLE_37_STABLE, MOODLE_38_STABLE
-
MDL-57046_mdl_files_reference_cleanup
-
Records in mdl_files_reference are not deleted, even when resource that linked to them is removed and there are no more references from mdl_files to mdl_files_reference.
Basically the table will grow forever - which is a problem for bigger Moodle installations.
To reproduce the issue:
1. Configure "File system" repository, put a file there.
2. Create new course with a file resource. Choose a file from file system repository and pick "Create an alias/shortcut to the file" option.
3. Review mdl_files_reference table and notice new entry there.
4. Review mdl_files table - there will be 2 new records linking to mdl_files_reference (with ID set in column referencefileid) - one in user/draft and another in mod_resource/content.
5. Delete resource.
6. mod_resource/content entries from mdl_files will be gone, entry in mdl_files_reference stays.
7. Edit your draft entries to speed up their clean up, e.g. run
moosh sql-run 'UPDATE mdl_files SET timecreated = 0 WHERE component="user" AND filearea="draft" AND filename="."'
|
8. Clear draft files
./admin/tool/task/cli/schedule_task.php --execute=\\core\\task\\file_trash_cleanup_task
|
9. Notice that all entries from mdl_files that were referencing mdl_files_reference table are gone. The entry in mdl_files_reference is still there.