Commit b469a04e authored by Robert Lyon's avatar Robert Lyon Committed by Gerrit Code Review
Browse files

Merge "Bug 1681569: Check to see if directory is readable before looping thru it"

parents 8774d393 53ab0d57
......@@ -765,21 +765,26 @@ function rmdirr($dirname)
return unlink($dirname);
}
// Loop through the folder
$dir = dir($dirname);
while (false !== $entry = $dir->read()) {
// Skip pointers
if ($entry == '.' || $entry == '..') {
continue;
// Directory sanity check - because the results of function file_exists are cached
// we can end up here with the dir already deleted on load-balanced machines
if (is_dir($dirname) && is_readable($dirname)) {
// Loop through the folder
$dir = dir($dirname);
while (false !== $entry = $dir->read()) {
// Skip pointers
if ($entry == '.' || $entry == '..') {
continue;
}
// Recurse
rmdirr($dirname . '/' . $entry);
}
// Recurse
rmdirr($dirname . '/' . $entry);
// Clean up
$dir->close();
return rmdir($dirname);
}
else {
return false;
}
// Clean up
$dir->close();
return rmdir($dirname);
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment