From d421a973d1d62b786aff4f25d9d9059a5a8acbd6 Mon Sep 17 00:00:00 2001 From: Rajesh Taneja Date: Tue, 31 Mar 2015 14:39:01 +0800 Subject: [PATCH 1/2] MDL-48605 unit_test: Fixed file_temp_cleanup_task touch should only work on temp and below dir's. With path we get temp/.. and temp/. So we were modfying moodledata dir as well and it was failing because of permission issues. --- lib/classes/task/file_temp_cleanup_task.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/classes/task/file_temp_cleanup_task.php b/lib/classes/task/file_temp_cleanup_task.php index 516e3c516cc..0b0253ac3b2 100644 --- a/lib/classes/task/file_temp_cleanup_task.php +++ b/lib/classes/task/file_temp_cleanup_task.php @@ -88,8 +88,10 @@ class file_temp_cleanup_task extends scheduled_task { } } } else { - // Return the time modified to the original date. - touch($node, $modifieddateobject[$node]); + // Return the time modified to the original date only for real files. + if ($iter->isDir() && !$iter->isDot()) { + touch($node, $modifieddateobject[$node]); + } } } } From d83a1c11a2dd5aece9c87ef2048c3a14a260601a Mon Sep 17 00:00:00 2001 From: Rajesh Taneja Date: Tue, 31 Mar 2015 21:45:23 +0800 Subject: [PATCH 2/2] MDL-48605 unit_test: Only touch real file/dir --- lib/tests/scheduled_task_test.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/tests/scheduled_task_test.php b/lib/tests/scheduled_task_test.php index 95a5a0dc3a6..9c1f95990ee 100644 --- a/lib/tests/scheduled_task_test.php +++ b/lib/tests/scheduled_task_test.php @@ -395,8 +395,10 @@ class core_scheduled_task_testcase extends advanced_testcase { $iter = new \RecursiveIteratorIterator($dir, \RecursiveIteratorIterator::CHILD_FIRST); for ($iter->rewind(); $iter->valid(); $iter->next()) { - $node = $iter->getRealPath(); - touch($node, time() - (8 * 24 * 3600)); + if ($iter->isDir() && !$iter->isDot()) { + $node = $iter->getRealPath(); + touch($node, time() - (8 * 24 * 3600)); + } } // Run the scheduled task again to remove all of the files and directories.