From b5b18eb57230dca00f464d18e66a82c168d92630 Mon Sep 17 00:00:00 2001 From: Rajesh Taneja Date: Fri, 15 Jul 2016 13:51:33 +0800 Subject: [PATCH] MDL-55174 core_testing: Use proper directory separator While searching for existing files if directory separator is not correct then original files and directories will be deleted. So use DIRECTORY_SEPARATOR. --- lib/testing/classes/util.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/testing/classes/util.php b/lib/testing/classes/util.php index 1eabd847965..01d25e48ea4 100644 --- a/lib/testing/classes/util.php +++ b/lib/testing/classes/util.php @@ -749,7 +749,7 @@ abstract class testing_util { if (file_exists(self::get_dataroot() . '/filedir')) { $handle = opendir(self::get_dataroot() . '/filedir'); while (false !== ($item = readdir($handle))) { - if (in_array('filedir/' . $item, $childclassname::$datarootskiponreset)) { + if (in_array('filedir' . DIRECTORY_SEPARATOR . $item, $childclassname::$datarootskiponreset)) { continue; } if (is_dir(self::get_dataroot()."/filedir/$item")) { @@ -961,8 +961,10 @@ abstract class testing_util { if (!file_exists($jsonfilepath)) { $listfiles = array(); - $listfiles['filedir/.'] = 'filedir/.'; - $listfiles['filedir/..'] = 'filedir/..'; + $currentdir = 'filedir' . DIRECTORY_SEPARATOR . '.'; + $parentdir = 'filedir' . DIRECTORY_SEPARATOR . '..'; + $listfiles[$currentdir] = $currentdir; + $listfiles[$parentdir] = $parentdir; $filedir = self::get_dataroot() . '/filedir'; if (file_exists($filedir)) {