Page MenuHomePhabricator

Allow Mediawiki to store file size greater than 32 bits
Open, Needs TriagePublic

Description

Currently, MediaWiki stores images size as a unsigned 32 bits information. That means a limit of 4 GB (2^32 = 4294967296 bytes).

If we need to allow MediaWiki to store larger files, we need to store this information as 64 bits integers.

The following fields are concerned:

  • image.img_size
  • oldimage.oi_size
  • filearchive.fa_size
  • uploadstash.us_size (to be confirmed, as this uses chunked uploads?)

Event Timeline

 image.img_size
 oldimage.oi_size
 filearchive.fa_size
uploadstash.us_size (to be confirmed, as this uses chunked uploads?)

No, all these are fine. A 32 bit field can store the number 2^32 fine. These fields should work fine as long as the file size is less than 2^(2^32), which we're in no danger of approaching :)

No, all these are fine. A 32 bit field can store the number 2^32 fine. These fields should work fine as long as the file size is less than 2^(2^32), which we're in no danger of approaching :)

Wait what? Don't you need 2^32 bits to store 2^(2^32)?

Bugreporter added a subscriber: Bugreporter.

Don't think it's true.

The fields are currently defined in tables.sql as int unsigned which is a 32-bit type with a range from 0 to 2^32 - 1 (one byte shy of 4 GiB). To record sizes of files of 4 GiB or higher, redefining them as bigint unsigned, a 64-bit type, would be required.

It will also be necessary to ensure that nothing else breaks when interpreting the large numbers as integers (PHP uses C long type for integers, which is 64 bits on Linux x86-64, so this should not be a problem in practice).