-
Bug
-
Resolution: Fixed
-
Critical
-
2.6.3, 2.7
-
MOODLE_26_STABLE, MOODLE_27_STABLE
-
MOODLE_26_STABLE, MOODLE_27_STABLE
-
MDL-45654-master -
When the cron function cron_delete_from_temp() runs and attempts
to remove anything older that 1 week, the directory remove will fail for a directory where a file has already been deleted from a child directory of this directory. This is since the mtime of the child directory is updated to whenever the file is deleted, which is not older that 1 week. But the parent directory is still in the list to be deleted. So you get this error that the deletion of the directory failed:
Failed removing directory '/vle/learn3acct/moodledata/temp/local_convertoldbackup.56.1236804135/user_files/654000'.
|
Failed removing directory '/vle/learn3acct/moodledata/temp/local_convertoldbackup.56.1236804135/user_files/546000'.
|
Failed removing directory '/vle/learn3acct/moodledata/temp/local_convertoldbackup.56.1236804135/user_files/480000'.
|
Failed removing directory '/vle/learn3acct/moodledata/temp/local_convertoldbackup.56.1236804135/user_files/600000'.
|
Failed removing directory '/vle/learn3acct/moodledata/temp/local_convertoldbackup.56.1236804135/user_files/675000'.
|
Failed removing directory '/vle/learn3acct/moodledata/temp/local_convertoldbackup.56.1236804135/user_files/119000'.
|
Failed removing directory '/vle/learn3acct/moodledata/temp/local_convertoldbackup.56.1236804135/user_files/47000'.
|
Failed removing directory '/vle/learn3acct/moodledata/temp/local_convertoldbackup.56.1236804135/user_files/754000'.
|
Failed removing directory '/vle/learn3acct/moodledata/temp/local_convertoldbackup.56.1236804135/user_files/755000'.
|
Failed removing directory '/vle/learn3acct/moodledata/temp/local_convertoldbackup.56.1236804135/user_files/417000'.
|
Failed removing directory '/vle/learn3acct/moodledata/temp/local_convertoldbackup.56.1236804135/user_files/720000'.
|
Failed removing directory '/vle/learn3acct/moodledata/temp/local_convertoldbackup.56.1236804135/user_files/788000'.
|
Failed removing directory '/vle/learn3acct/moodledata/temp/local_convertoldbackup.56.1236804135/user_files/455000'.
|
Failed removing directory '/vle/learn3acct/moodledata/temp/local_convertoldbackup.56.1236804135/user_files/461000'.
|
......
|
Failed removing directory '/vle/learn3acct/moodledata/temp/local_convertoldbackup.754.325959266/moddata/oucontent'.
|
Failed removing directory '/vle/learn3acct/moodledata/temp/local_convertoldbackup.6.283880280/course_files/hires/a330_VS_Plate_2_4_DONE'.
|
Failed removing directory '/vle/learn3acct/moodledata/temp/local_convertoldbackup.6.283880280/course_files/hires'.
|
Failed removing directory '/vle/learn3acct/moodledata/temp/local_convertoldbackup.6.283880280/course_files'.
|
Failed removing directory '/vle/learn3acct/moodledata/temp/local_convertoldbackup.6.871256423/course_files/hires/a330_VS_Plate_2_4_DONE'.
|
Failed removing directory '/vle/learn3acct/moodledata/temp/local_convertoldbackup.6.871256423/course_files/hires'.
|
Failed removing directory '/vle/learn3acct/moodledata/temp/local_convertoldbackup.6.871256423/course_files'.
|
if you create the following in moodledata/temp:
mkdir -p dir_2/dir_2_1
|
touch -t 04070101 dir_2/dir_2_1/file_2_1_1
|
touch -t 04070101 dir_2/dir_2_1
|
touch -t 04070101 dir_2
|
when cron_delete_from_temp() runs in cron ( only every 1 in 5 ish), it should fail to delete dir_2 since dir_2_1 still exists but file_2_1_1 was deleted.
I found that since this function uses the Directory Iterator etc, the simplest fix would be to check if the Directory has any Children, unfortunately this doesn't seem to work correctly, I think due to the '.' and '..' entries.
The solution I have found that has minimal code change is to use the glob function which ignores the '.' and '..' entries.
In investigating this issue, I found that the unit test, /lib/tests/cronlib_test.php, has a unit test for this functionality but the timestamps used do not seem to be what was intended.
Checked phpunit tests on linux (centos6) and windows (windows7) with php 5.5 and Postgresql