X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fupload%2FUploadBase.php;h=f8624d02c532e0a25fe081efee855c5ca609f06e;hb=4aa9e10995aff01bee946eb592c39a885356a85f;hp=f600e321355791caa96f57e46487606986b80dea;hpb=ff9f2fa33719753ff0c708f9b4a84c57593b9e58;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/upload/UploadBase.php b/includes/upload/UploadBase.php index f600e32135..f8624d02c5 100644 --- a/includes/upload/UploadBase.php +++ b/includes/upload/UploadBase.php @@ -1919,6 +1919,9 @@ abstract class UploadBase { } /** + * Get the MediaWiki maximum uploaded file size for given type of upload, based on + * $wgMaxUploadSize. + * * @param null|string $forType * @return int */ @@ -1936,6 +1939,25 @@ abstract class UploadBase { } } + /** + * Get the PHP maximum uploaded file size, based on ini settings. If there is no limit or the + * limit can't be guessed, returns a very large number (PHP_INT_MAX). + * + * @since 1.27 + * @return int + */ + public static function getMaxPhpUploadSize() { + $phpMaxFileSize = wfShorthandToInteger( + ini_get( 'upload_max_filesize' ) ?: ini_get( 'hhvm.server.upload.upload_max_file_size' ), + PHP_INT_MAX + ); + $phpMaxPostSize = wfShorthandToInteger( + ini_get( 'post_max_size' ) ?: ini_get( 'hhvm.server.max_post_size' ), + PHP_INT_MAX + ) ?: PHP_INT_MAX; + return min( $phpMaxFileSize, $phpMaxPostSize ); + } + /** * Get the current status of a chunked upload (used for polling) * @@ -1968,7 +1990,7 @@ abstract class UploadBase { if ( $value === false ) { $cache->delete( $key ); } else { - $cache->set( $key, $value, 86400 ); + $cache->set( $key, $value, $cache::TTL_DAY ); } } }