Skip to content

Commit

Permalink
MDL-38570 admin: fix cron_delete_from_temp on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Gus authored and danpoltawski committed Sep 12, 2013
1 parent ef9ca10 commit c4012e7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/cronlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,7 @@ function cron_delete_from_temp() {
$iter = new RecursiveIteratorIterator($dir, RecursiveIteratorIterator::CHILD_FIRST);

for ($iter->rewind(); $iter->valid(); $iter->next()) {
$node = $iter->getPathname();
$node = $iter->getRealPath();
if (!is_readable($node)) {
continue;
}
Expand Down
20 changes: 11 additions & 9 deletions lib/tests/cronlib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class cronlib_testcase extends basic_testcase {
*/
public function cron_delete_from_temp_provider() {
global $CFG;

$tmpdir = realpath($CFG->tempdir);
$time = time();

$weekstime = $time - strtotime('1 week');
Expand Down Expand Up @@ -97,14 +99,14 @@ public function cron_delete_from_temp_provider() {
array(
array($node1, $node2, $node3, $node4, $node5, $node6, $node7, $node8, $node9, $node10),
array(
"$CFG->tempdir/dir1",
"$CFG->tempdir/dir1/dir1_1",
"$CFG->tempdir/dir1/dir1_1/dir1_2",
"$CFG->tempdir/dir1/dir1_1/dir1_2/file2",
"$CFG->tempdir/dir1/dir1_4",
"$CFG->tempdir/dir1/dir1_4/file2",
"$CFG->tempdir/dir2",
"$CFG->tempdir/file1",
$tmpdir.DIRECTORY_SEPARATOR.'dir1',
$tmpdir.DIRECTORY_SEPARATOR.'dir1'.DIRECTORY_SEPARATOR.'dir1_1',
$tmpdir.DIRECTORY_SEPARATOR.'dir1'.DIRECTORY_SEPARATOR.'dir1_1'.DIRECTORY_SEPARATOR.'dir1_2',
$tmpdir.DIRECTORY_SEPARATOR.'dir1'.DIRECTORY_SEPARATOR.'dir1_1'.DIRECTORY_SEPARATOR.'dir1_2'.DIRECTORY_SEPARATOR.'file2',
$tmpdir.DIRECTORY_SEPARATOR.'dir1'.DIRECTORY_SEPARATOR.'dir1_4',
$tmpdir.DIRECTORY_SEPARATOR.'dir1'.DIRECTORY_SEPARATOR.'dir1_4'.DIRECTORY_SEPARATOR.'file2',
$tmpdir.DIRECTORY_SEPARATOR.'dir2',
$tmpdir.DIRECTORY_SEPARATOR.'file1',
)
),
array(
Expand Down Expand Up @@ -143,7 +145,7 @@ public function test_cron_delete_from_temp($nodes, $expected) {
$actual = array();
for ($iter->rewind(); $iter->valid(); $iter->next()) {
if (!$iter->isDot()) {
$actual[] = $iter->getPathname();
$actual[] = $iter->getRealPath();
}
}

Expand Down

0 comments on commit c4012e7

Please sign in to comment.