use wcf\data\DatabaseObjectEditor;
use wcf\data\file\temporary\FileTemporary;
+use wcf\data\file\thumbnail\FileThumbnailEditor;
+use wcf\data\file\thumbnail\FileThumbnailList;
use wcf\util\FileUtil;
/**
*/
protected static $baseClass = File::class;
+ public function deleteFiles(): void
+ {
+ @\unlink($this->getPathname());
+
+ $thumbnailIDs = \array_column($this->getThumbnails(), 'thumbnailID');
+ if ($thumbnailIDs !== []) {
+ FileThumbnailEditor::deleteAll($thumbnailIDs);
+ }
+ }
+
+ public static function deleteAll(array $objectIDs = [])
+ {
+ $fileList = new FileList();
+ $fileList->getConditionBuilder()->add("fileID IN (?)", [$objectIDs]);
+ $fileList->readObjects();
+ $files = $fileList->getObjects();
+ if (\count($files) === 0) {
+ return 0;
+ }
+
+ $thumbnailList = new FileThumbnailList();
+ $thumbnailList->getConditionBuilder()->add("fileID IN (?)", [$objectIDs]);
+ $thumbnailList->readObjects();
+ foreach ($thumbnailList as $thumbnail) {
+ $files[$thumbnail->fileID]->addThumbnail($thumbnail);
+ }
+
+ foreach ($files as $file) {
+ (new FileEditor($file))->deleteFiles();
+ }
+
+ return parent::deleteAll($objectIDs);
+ }
+
public static function createFromTemporary(FileTemporary $fileTemporary): File
{
$pathname = $fileTemporary->getPathname();
use wcf\data\DatabaseObjectEditor;
use wcf\data\file\File;
use wcf\system\file\processor\ThumbnailFormat;
-use wcf\util\FileUtil;
/**
* @author Alexander Ebert
*/
protected static $baseClass = FileThumbnail::class;
+ public function deleteFiles(): void
+ {
+ @\unlink($this->getPath() . $this->getSourceFilename());
+ }
+
+ public static function deleteAll(array $objectIDs = [])
+ {
+ $thumbnailList = new FileThumbnailList();
+ $thumbnailList->getConditionBuilder()->add("thumbnailID IN (?)", [$objectIDs]);
+ $thumbnailList->readObjects();
+
+ if (\count($thumbnailList) === 0) {
+ return 0;
+ }
+
+ foreach ($thumbnailList as $thumbnail) {
+ (new FileThumbnailEditor($thumbnail))->deleteFiles();
+ }
+
+ return parent::deleteAll($objectIDs);
+ }
+
public static function createFromTemporaryFile(
File $file,
ThumbnailFormat $format,