Skip to content

Commit e05a0ef

Browse files
authored
Merge pull request #17967 from marcusmoore/fixes/17963-delete-file-via-api-fix
Fixed #17963 - over eager deletion of asset files via api
2 parents 00b9ba2 + 4bbbd78 commit e05a0ef

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

app/Http/Controllers/Api/UploadedFilesController.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,12 @@ public function destroy($object_type, $id, $file_id) : JsonResponse
193193

194194

195195
// Check for the file
196-
$log = Actionlog::find($file_id)->where('item_type', self::$map_object_type[$object_type])
197-
->where('item_id', $object->id)->first();
196+
$log = Actionlog::query()
197+
->where('id', $file_id)
198+
->where('action_type', 'uploaded')
199+
->where('item_type', self::$map_object_type[$object_type])
200+
->where('item_id', $object->id)
201+
->first();
198202

199203
if ($log) {
200204
// Check the file actually exists, and delete it
@@ -213,4 +217,4 @@ public function destroy($object_type, $id, $file_id) : JsonResponse
213217
return response()->json(Helper::formatStandardApiResponse('error', null, trans_choice('general.file_upload_status.delete.error', 1)), 500);
214218

215219
}
216-
}
220+
}

0 commit comments

Comments
 (0)