Work around broken HHVM ini_get() for 'upload_max_filesize' and 'post_max_size'
authorBartosz Dziewoński <matma.rex@gmail.com>
Fri, 23 Oct 2015 16:03:43 +0000 (18:03 +0200)
committerOri.livneh <ori@wikimedia.org>
Sun, 8 Nov 2015 19:48:23 +0000 (19:48 +0000)
commited6648427a86d6893deb219081a96e337a1141cb
treebe5df4d856ccf8b7cc130fe2456dd63081d79398
parent0f9242e0cde5687c43d90270a4d7841da109a677
Work around broken HHVM ini_get() for 'upload_max_filesize' and 'post_max_size'

In HHVM, the settings 'upload_max_filesize' and 'post_max_size' are
not available via ini_get() due to some long-standing bug
(https://github.com/facebook/hhvm/issues/4993). Instead, one can use
'hhvm.server.upload.upload_max_file_size' and 'hhvm.server.max_post_size'
(in a typical PHP fashion, their names are subtly different than the
originals as to increase the potential for confusion).

Added a new method UploadBase::getMaxPhpUploadSize() to handle this.

Additionally:
* 'post_max_size' can be set to 0, which is equivalent to no limit.
  Handle this correctly.
* $wgMaxUploadSize can be an array structure, instead of just a number.
  Handle this correctly by using UploadBase::getMaxUploadSize().
* When no maximum is set, use PHP_INT_MAX rather than 1e100. It should
  be big enough, and the latter is a float, results in 0 when cast to
  int, and doesn't look as pretty when formatted in GB in the interface.

Bug: T116347
Change-Id: Idf707253eeae1b90792a7e26d2ab66d1317e67ae
RELEASE-NOTES-1.27
includes/Setup.php
includes/WebRequestUpload.php
includes/specials/SpecialUpload.php
includes/upload/UploadBase.php
includes/upload/UploadFromFile.php