==== External libraries ====
=== Bug fixes in 1.27 ===
+* Special:Upload will now display correct maximum allowed file size when running
+ under HHVM (T116347).
=== Action API changes in 1.27 ===
* Added list=allrevisions.
// upload size.
$wgMinUploadChunkSize = min(
$wgMinUploadChunkSize,
- $wgMaxUploadSize,
- wfShorthandToInteger( ini_get( 'upload_max_filesize' ), 1e100 ),
- wfShorthandToInteger( ini_get( 'post_max_size' ), 1e100 ) - 1024 # Leave room for other parameters
+ UploadBase::getMaxUploadSize( 'file' ),
+ UploadBase::getMaxPhpUploadSize(),
+ ( wfShorthandToInteger(
+ ini_get( 'post_max_size' ) ?: ini_get( 'hhvm.server.max_post_size' ),
+ PHP_INT_MAX
+ ) ?: PHP_INT_MAX ) - 1024 // Leave some room for other POST parameters
);
/**
}
$contentLength = $this->request->getHeader( 'CONTENT_LENGTH' );
- if ( $contentLength > wfShorthandToInteger( ini_get( 'post_max_size' ) ) ) {
+ $maxPostSize = wfShorthandToInteger(
+ ini_get( 'post_max_size' ) ?: ini_get( 'hhvm.server.max_post_size' ),
+ 0
+ );
+
+ if ( $maxPostSize && $contentLength > $maxPostSize ) {
# post_max_size is exceeded
return true;
}
);
}
- $this->mMaxUploadSize['file'] = UploadBase::getMaxUploadSize( 'file' );
- # Limit to upload_max_filesize unless we are running under HipHop and
- # that setting doesn't exist
- if ( !wfIsHHVM() ) {
- $this->mMaxUploadSize['file'] = min( $this->mMaxUploadSize['file'],
- wfShorthandToInteger( ini_get( 'upload_max_filesize' ) ),
- wfShorthandToInteger( ini_get( 'post_max_size' ) )
- );
- }
+ $this->mMaxUploadSize['file'] = min(
+ UploadBase::getMaxUploadSize( 'file' ),
+ UploadBase::getMaxPhpUploadSize()
+ );
$help = $this->msg( 'upload-maxfilesize',
$this->getContext()->getLanguage()->formatSize( $this->mMaxUploadSize['file'] )
}
/**
+ * Get the MediaWiki maximum uploaded file size for given type of upload, based on
+ * $wgMaxUploadSize.
+ *
* @param null|string $forType
* @return int
*/
}
}
+ /**
+ * 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)
*
'status' => UploadBase::FILE_TOO_LARGE,
'max' => min(
self::getMaxUploadSize( $this->getSourceType() ),
- wfShorthandToInteger( ini_get( 'upload_max_filesize' ) ),
- wfShorthandToInteger( ini_get( 'post_max_size' ) )
+ self::getMaxPhpUploadSize()
),
);
}