Skip to content

Commit 9ba3910

Browse files
committed
Rename the event and only fire it for uploaded files
The method `createFromExistingFile()` is a programmatic call that usually occurs during a data import. Any additional actions, such as the modification of images, should only be carried out during an upload or when rebuilding data.
1 parent b90e799 commit 9ba3910

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

wcfsetup/install/files/lib/data/file/FileEditor.class.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use wcf\data\file\temporary\FileTemporary;
77
use wcf\data\file\thumbnail\FileThumbnailEditor;
88
use wcf\data\file\thumbnail\FileThumbnailList;
9-
use wcf\event\file\FileCreated;
9+
use wcf\event\file\UploadCompleted;
1010
use wcf\system\event\EventHandler;
1111
use wcf\system\file\processor\FileProcessor;
1212
use wcf\system\image\ImageHandler;
@@ -120,7 +120,7 @@ public static function createFromTemporary(FileTemporary $fileTemporary): File
120120
$filePath . $file->getSourceFilename()
121121
);
122122

123-
$event = new FileCreated($file);
123+
$event = new UploadCompleted($file);
124124
EventHandler::getInstance()->fire($event);
125125

126126
return $event->getFile();
@@ -191,10 +191,7 @@ public static function createFromExistingFile(
191191
$filePath . $file->getSourceFilename()
192192
);
193193

194-
$event = new FileCreated($file);
195-
EventHandler::getInstance()->fire($event);
196-
197-
return $event->getFile();
194+
return $file;
198195
}
199196

200197
/**

wcfsetup/install/files/lib/event/file/FileCreated.class.php renamed to wcfsetup/install/files/lib/event/file/UploadCompleted.class.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
use wcf\event\IPsr14Event;
77

88
/**
9-
* Fired when a file was created before it is returned to the callee.
9+
* Fired when a file was uploaded before it is returned to the callee.
1010
*
1111
* @author Alexander Ebert
1212
* @copyright 2001-2025 WoltLab GmbH
1313
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
1414
* @since 6.1
1515
*/
16-
final class FileCreated implements IPsr14Event
16+
final class UploadCompleted implements IPsr14Event
1717
{
1818
public function __construct(
1919
private File $file,
@@ -25,7 +25,8 @@ public function getFile(): File
2525
}
2626

2727
/**
28-
* Reloads the file to fetch updated values.
28+
* Reloads the file to fetch updated values. This must be called whenever
29+
* the uploaded files has been modified by a listener.
2930
*/
3031
public function reload(): void
3132
{

0 commit comments

Comments
 (0)