diff -u b/core/modules/simpletest/simpletest.module b/core/modules/simpletest/simpletest.module --- b/core/modules/simpletest/simpletest.module +++ b/core/modules/simpletest/simpletest.module @@ -531,23 +531,7 @@ // We can not use file_unmanaged_delete_recursive because it // deliberately only removes visible files with write permission. chmod($path, 0700); - // We can't use a RecursiveDirectoryIterator either because the directories - // might need chmod first. - if (is_dir($path)) { - $dir = dir($path); - while (($entry = $dir->read()) !== FALSE) { - if ($entry == '.' || $entry == '..') { - continue; - } - $entry_path = $path . '/' . $entry; - _simpletest_delete_recursive($entry_path); - } - $dir->close(); - rmdir($path); - } - else { - unlink($path); - } + file_unmanaged_delete_recursive($path, '_simpletest_delete_recursive'); } /** only in patch2: unchanged: --- a/core/includes/file.inc +++ b/core/includes/file.inc @@ -1325,6 +1325,8 @@ function file_unmanaged_delete($path) { * * @param $path * A string containing either an URI or a file or directory path. + * @param $function + * The function to recurse with. _simpletest_delete_recursive() uses this. * * @return * TRUE for success or if path does not exist, FALSE in the event of an @@ -1332,7 +1334,7 @@ function file_unmanaged_delete($path) { * * @see file_unmanaged_delete() */ -function file_unmanaged_delete_recursive($path) { +function file_unmanaged_delete_recursive($path, $function = 'file_unmanaged_delete_recursive') { if (is_dir($path)) { $dir = dir($path); while (($entry = $dir->read()) !== FALSE) { @@ -1340,7 +1342,7 @@ function file_unmanaged_delete_recursive($path) { continue; } $entry_path = $path . '/' . $entry; - file_unmanaged_delete_recursive($entry_path); + $function($entry_path, $function); } $dir->close();