Site Health: Include new tests to check for the ability to upload files.

Several new checks:

* `max_file_uploads`
* `file_uploads`
* `post_max_size`
* `upload_max_filesize`
* `upload_max`
* `max_file_uploads`

In addition, new function `parse_ini_size()` that converts shorthand byte strings to bytes. Useful for size comparisons.

Fixes #50038.
Props dd32, donmhico, JavierCasares, SergeyBiryukov, ayeshrajans, Clorith, ipstenu, sabernhardt, whyisjake.


git-svn-id: https://develop.svn.wordpress.org/trunk@48535 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Jake Spurlock
2020-07-21 15:19:58 +00:00
parent 3ef1fa5c6d
commit 5ffe591bec
3 changed files with 147 additions and 0 deletions

View File

@@ -476,6 +476,38 @@ function size_format( $bytes, $decimals = 0 ) {
return false;
}
/**
* Converts a shorthand byte string to bytes.
*
* Useful when needing to compare two byte strings for size differences.
*
* E.g.
* "1G" (1 Gigabyte) = 1073741824
* "10M" (10 Megabytes) = 10485760
* "1K" (1 Kilobyte) = 1024
*
* @since 5.5.0
*
* @param string $size_string Shorthand byte string
* @return int $size_string converted to numberic bytes.
*/
function parse_ini_size( $size_string ) {
$size_string = trim( $size_string );
$last = strtolower( substr( $size_string, - 1 ) );
$value = intval( $size_string );
switch ( $last ) {
case 'g':
return (int) $value * GB_IN_BYTES;
case 'm':
return (int) $value * MB_IN_BYTES;
case 'k':
return (int) $value * KB_IN_BYTES;
default:
return (int) $value;
}
}
/**
* Convert a duration to human readable format.
*