aboutsummaryrefslogtreecommitdiffstats
path: root/includes/libs/filebackend
diff options
context:
space:
mode:
authorBrian Wolff <bawolff+wn@gmail.com>2023-10-05 22:02:09 -0700
committerKrinkle <krinkle@fastmail.com>2023-10-25 17:05:03 +0000
commit29b5fd433a22e5320a1b1280028de4fa857c0ae1 (patch)
tree56d0967f0f1b7f3a1e861fe9ac488c28e287a13c /includes/libs/filebackend
parent7eb8efa71e7884d79c155d77e8f002ee8b5cb68e (diff)
downloadmediawikicore-29b5fd433a22e5320a1b1280028de4fa857c0ae1.tar.gz
mediawikicore-29b5fd433a22e5320a1b1280028de4fa857c0ae1.zip
filebackend: Allow uploading files up to 32 GB with FSFileBackend
The SwiftBackend theoretical max file size was increased to 5 GB Sysadmins of MediaWiki are in a better position to judge what is acceptable performance-wise for uploaded files than we are. The answer presumably depends significantly on the hardware mediawiki is running under. This increases the max limit to 32 GB (previously 4GB). With files this big, operations such as copying and calculating SHA1 do become expensive. However everything still works, albeit with some delay (I tested on a laptop with HDD, I imagine things are significantly faster with an NVMe drive). This changes the overall FileBackendStore limit which affects all subclasses that haven't overriden the limit, including those from extensions. Swift was set to 5GB as that backend has to change the way it uses the Swift API for objects larger than 5GB. This should not affect ordinary users as $wgMaxUploadSize is by default only 100 MB in MediaWiki (4GB in Wikimedia). Bug: T191805 Change-Id: Id091d51b620edbeea2d9df8c75422807bfc7aea0
Diffstat (limited to 'includes/libs/filebackend')
-rw-r--r--includes/libs/filebackend/FileBackendStore.php4
-rw-r--r--includes/libs/filebackend/SwiftFileBackend.php5
2 files changed, 7 insertions, 2 deletions
diff --git a/includes/libs/filebackend/FileBackendStore.php b/includes/libs/filebackend/FileBackendStore.php
index b9b3874e829f..eeabaf88f30f 100644
--- a/includes/libs/filebackend/FileBackendStore.php
+++ b/includes/libs/filebackend/FileBackendStore.php
@@ -54,7 +54,7 @@ abstract class FileBackendStore extends FileBackend {
/** @var callable|null Method to get the MIME type of files */
protected $mimeCallback;
- protected $maxFileSize = 4294967296; // integer bytes (4GiB)
+ protected $maxFileSize = 32 * 1024 * 1024 * 1024; // integer bytes (32GiB)
protected const CACHE_TTL = 10; // integer; TTL in seconds for process cache entries
protected const CACHE_CHEAP_SIZE = 500; // integer; max entries in "cheap cache"
@@ -100,7 +100,7 @@ abstract class FileBackendStore extends FileBackend {
* @return int Bytes
*/
final public function maxFileSizeInternal() {
- return $this->maxFileSize;
+ return min( $this->maxFileSize, PHP_INT_MAX );
}
/**
diff --git a/includes/libs/filebackend/SwiftFileBackend.php b/includes/libs/filebackend/SwiftFileBackend.php
index ce21f3fd9124..29bb87cffdbb 100644
--- a/includes/libs/filebackend/SwiftFileBackend.php
+++ b/includes/libs/filebackend/SwiftFileBackend.php
@@ -160,6 +160,11 @@ class SwiftFileBackend extends FileBackendStore {
$this->writeUsers = $config['writeUsers'] ?? [];
$this->secureReadUsers = $config['secureReadUsers'] ?? [];
$this->secureWriteUsers = $config['secureWriteUsers'] ?? [];
+ // Per https://docs.openstack.org/swift/latest/overview_large_objects.html
+ // we need to split objects if they are larger than 5 GB. Support for
+ // splitting objects has not yet been implemented by this class
+ // so limit max file size to 5GiB.
+ $this->maxFileSize = 5 * 1024 * 1024 * 1024;
}
public function setLogger( LoggerInterface $logger ) {