mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-10 07:06:40 +02:00
Avoid using GlobIterator since it seems to trip up open_basedir restrictions, fixes #204
This commit is contained in:
@@ -93,22 +93,20 @@ class RotatingFileHandler extends StreamHandler
|
|||||||
if (!empty($fileInfo['extension'])) {
|
if (!empty($fileInfo['extension'])) {
|
||||||
$glob .= '.'.$fileInfo['extension'];
|
$glob .= '.'.$fileInfo['extension'];
|
||||||
}
|
}
|
||||||
$iterator = new \GlobIterator($glob);
|
$logFiles = glob($glob);
|
||||||
$count = $iterator->count();
|
if ($this->maxFiles >= count($logFiles)) {
|
||||||
if ($this->maxFiles >= $count) {
|
|
||||||
// no files to remove
|
// no files to remove
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sorting the files by name to remove the older ones
|
// Sorting the files by name to remove the older ones
|
||||||
$array = iterator_to_array($iterator);
|
usort($logFiles, function($a, $b) {
|
||||||
usort($array, function($a, $b) {
|
return strcmp($b, $a);
|
||||||
return strcmp($b->getFilename(), $a->getFilename());
|
|
||||||
});
|
});
|
||||||
|
|
||||||
foreach (array_slice($array, $this->maxFiles) as $file) {
|
foreach (array_slice($logFiles, $this->maxFiles) as $file) {
|
||||||
if ($file->isWritable()) {
|
if (is_writable($file)) {
|
||||||
unlink($file->getRealPath());
|
unlink($file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user