Skip to content

Commit

Permalink
Make Assets::deleteFoldersByIds() more defensive
Browse files Browse the repository at this point in the history
Resolves #16147
  • Loading branch information
brandonkelly committed Nov 19, 2024
1 parent 82e893f commit cbf4189
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Unreleased

- Fixed an error that could occur if an invalid folder ID was passed to `craft\services\Assets::deleteFoldersByIds()`. ([#16147](https://github.com/craftcms/cms/pull/16147))
- Fixed an RCE vulnerability.

## 4.13.1.1 - 2024-11-18
Expand Down
6 changes: 5 additions & 1 deletion src/services/Assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,13 @@ public function deleteFoldersByIds(int|array $folderIds, bool $deleteDir = true)

foreach ((array)$folderIds as $folderId) {
$folder = $this->getFolderById((int)$folderId);
if (!$folder) {
continue;
}

$folders[] = $folder;

if ($folder && $deleteDir) {
if ($folder->path && $deleteDir) {
$volume = $folder->getVolume();
try {
$volume->deleteDirectory($folder->path);
Expand Down

0 comments on commit cbf4189

Please sign in to comment.