Site Health: Clarify the recommendation in file uploads test when `post_max_size` is defined as `0`.

This adds a more descriptive text in scenarios where `post_max_size` and `upload_max_filesize` differ, and `post_max_size` is set to a value of `0`.

In some scenarios, PHP may read `0` as a literal zero size, and not as unlimited, which it also means in other scenarios.

See https://www.php.net/manual/en/ini.core.php#ini.post-max-size for details, as PHP 5.3.4 introduced this behavior for literal zero interpretation when the content type of a request is `application/x-www-form-urlencoded` or is not registered with PHP.

Props Clorith, pixolin, helen, ratneshk.
Fixes #51466.
Built from https://develop.svn.wordpress.org/trunk@50263


git-svn-id: http://core.svn.wordpress.org/trunk@49908 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2021-02-09 12:05:07 +00:00
parent 98b855ed94
commit ea2ff553e9
2 changed files with 25 additions and 11 deletions

View File

@ -2176,16 +2176,30 @@ class WP_Site_Health {
'post_max_size',
'upload_max_filesize'
);
$result['status'] = 'recommended';
$result['description'] = sprintf(
'<p>%s</p>',
sprintf(
/* translators: 1: post_max_size, 2: upload_max_filesize */
__( 'The setting for %1$s is smaller than %2$s, this could cause some problems when trying to upload files.' ),
'<code>post_max_size</code>',
'<code>upload_max_filesize</code>'
)
);
$result['status'] = 'recommended';
if ( 0 === wp_convert_hr_to_bytes( $post_max_size ) ) {
$result['description'] = sprintf(
'<p>%s</p>',
sprintf(
/* translators: 1: post_max_size, 2: upload_max_filesize */
__( 'The setting for %1$s is currently configured as 0, this could cause some problems when trying to upload files through plugin or theme features that rely on various upload methods. It is recommended to configure this setting to a fixed value, ideally matching the value of %2$s, as some upload methods read the value 0 as either unlimited, or disabled.' ),
'<code>post_max_size</code>',
'<code>upload_max_filesize</code>'
)
);
} else {
$result['description'] = sprintf(
'<p>%s</p>',
sprintf(
/* translators: 1: post_max_size, 2: upload_max_filesize */
__( 'The setting for %1$s is smaller than %2$s, this could cause some problems when trying to upload files.' ),
'<code>post_max_size</code>',
'<code>upload_max_filesize</code>'
)
);
}
return $result;
}

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.7-beta1-50262';
$wp_version = '5.7-beta1-50263';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.