Skip to content

Commit

Permalink
fix(profiler): clear command does not work
Browse files Browse the repository at this point in the history
- The loop is supposed to delete the files first and then the directories.
- getPathInfo returns a SplFileInfo object for the parent (the folder in our case).
- A non-empty directory cannot be deleted.

Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
  • Loading branch information
kesselb committed Sep 20, 2024
1 parent bc52227 commit 4ae10aa
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/private/Profiler/FileProfilerStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ public function purge(): void {
$iterator = new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::CHILD_FIRST);

foreach ($iterator as $file) {
$file = (string)$file->getPathInfo();
if (is_file($file)) {
unlink($file);
$path = $file->getPathname();
if (is_file($path)) {
unlink($path);
} else {
rmdir($file);
rmdir($path);
}
}
}
Expand Down

0 comments on commit 4ae10aa

Please sign in to comment.