From cbeddcf98a8d721d1b2991479c37764deecb5d2c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Joshua=20R=C3=BCsweg?= Date: Thu, 31 Jan 2019 14:19:09 +0100 Subject: [PATCH] Add method removeFileByObject See #2825 --- .../lib/system/file/upload/UploadHandler.class.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/wcfsetup/install/files/lib/system/file/upload/UploadHandler.class.php b/wcfsetup/install/files/lib/system/file/upload/UploadHandler.class.php index 36f19c026b..e214508ebb 100644 --- a/wcfsetup/install/files/lib/system/file/upload/UploadHandler.class.php +++ b/wcfsetup/install/files/lib/system/file/upload/UploadHandler.class.php @@ -154,6 +154,16 @@ class UploadHandler extends SingletonFactory { return; } + $this->removeFileByObject($internalId, $file); + } + + /** + * Removes an file by file object. + * + * @param string $internalId + * @param UploadFile $file + */ + private function removeFileByObject($internalId, UploadFile $file) { $storage = $this->getStorage(); if ($file->isProcessed()) { @@ -165,7 +175,7 @@ class UploadHandler extends SingletonFactory { /** @var UploadFile $storageFile */ foreach ($storage[$internalId]['files'] as $id => $storageFile) { - if ($storageFile->getUniqueFileId() === $uniqueFileId) { + if ($storageFile->getUniqueFileId() === $file->getUniqueFileId()) { unset($storage[$internalId]['files'][$id]); break; } @@ -355,7 +365,7 @@ class UploadHandler extends SingletonFactory { /** @var UploadFile $file */ foreach ($files as $file) { if (!file_exists($file->getLocation())) { - $this->removeFile($internalId, $file->getUniqueFileId()); + $this->removeFile($internalId, $file); } } -- 2.20.1