Skip to content

Commit 8ad8e29

Browse files
committed
Adjust optimal chunk size for file uploads to a maximum of 99 MB
1 parent 0254d6e commit 8ad8e29

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

wcfsetup/install/files/lib/system/file/processor/FileProcessor.class.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
final class FileProcessor extends SingletonFactory
3737
{
3838
public const MAXIMUM_NUMBER_OF_CHUNKS = 255;
39+
public const MAXIMUM_CHUNK_SIZE = 99_000_000;
3940

4041
/**
4142
* @var array<string, ObjectType>
@@ -361,11 +362,13 @@ public function getOptimalChunkSize(): int
361362
{
362363
$postMaxSize = \ini_parse_quantity(\ini_get('post_max_size'));
363364
if ($postMaxSize === 0) {
364-
// Disabling it is fishy, assume a more reasonable limit of 100 MB.
365-
$postMaxSize = 100_000_000;
365+
// Disabling it is fishy, assume a more reasonable limit of 99 MB.
366+
return self::MAXIMUM_CHUNK_SIZE;
366367
}
367368

368-
return $postMaxSize;
369+
// 99 MB is a reasonable upper limit that also plays nice with services
370+
// like Cloudflare that usually come with a 100 MB request limit.
371+
return \min(self::MAXIMUM_CHUNK_SIZE, $postMaxSize);
369372
}
370373

371374
public function getMaximumFileSize(): int

0 commit comments

Comments
 (0)